views:

32

answers:

3

Hey Everyone,

What would be the most efficient way to check for numbers in a field that would contain a few letters? I would like to do this if the where statement as possible.

The data would look something like this:

3833N4323 32N907654 5W5840904

A: 
select ISNUMERIC(data)
Gabriel McAdams
+1  A: 

Checking for at least one number in a field (corrected):

WHERE PATINDEX('%[0-9]%', field) != 0

Checking for only numbers in a field:

WHERE ISNUMERIC(field)
enbuyukfener
how is this?AND PATINDEX('%[^0-9]%', pq.ReportNumber) > 1
chopps
You have the REGEXP keyword on SQL Server? What version of SQL Server is that?
Mark Byers
SQL Server 2005
chopps
This seems to work.AND PATINDEX('%[0-9^]%', pq.ReportNumber) > 1
chopps
A: 

A simple LIKE to find any number will suffice...

...WHERE LIKE '%[0-9]%'
gbn