ArchieTiger
ArchieTiger

Reputation: 2243

Query to retrieve rows where values are empty or numeric only

I need assistance with this. Assuming the folllowing table:

http://img820.imageshack.us/img820/6821/captureior.png

I need a SQL server query to select row 2 only (S1) and retrieve which item in the column(i.e. S1...S5) doesnt have k

That returns something like this:

 S1
 S2
 T1
 T2
 T3
 S3
 S4

(I intend to bind the rows items to a listbox that)

Upvotes: 1

Views: 1621

Answers (1)

Shivan Dragon
Shivan Dragon

Reputation: 15219

Well, with plain vanilla SQL you have no built-in way to check if a given value is numeric or not. however, for your particular case you can simply check if the value is not null and doesn't contain k:

select * from YourTable where sr is not null and sr not like '%k%'

If there's other possible non numerical characters than k that can be in the table, your best bet is to make some stored procedure that checks each character of a given strig if it's numeric or not and use that

Upvotes: 2

Related Questions