Reputation: 644
I have a long list in a varchar column (SQL Server) with data like:
Hello World
Hello World 2
1 Hello World
Again this is Hello World
Hello 100 World
500
I want to SELECT all the strings which contain a number in it. For example, in above, I need:
Hello World 2
1 Hello World
Hello 100 World
500
How can I do it with SELECT SQL?
Upvotes: 2
Views: 134
Reputation: 10285
You can Use Regular Expression [0-9]
which will select all rows with numbers between 0 and 9
Declare @tab as table(data varchar(50))
insert into @tab values
('Hello World 3'),('Hello World')
select * from @tab where data like '%[0-9]%'
OUTPUT
Hello World 3
Upvotes: 3