tags:

views:

49

answers:

2

Possible Duplicate:
How to get only numeric column values?

I am trying to write a T-SQL query that only returns rows where a specific column only contains numbers.

something like

select * from table where column like '[0-9]%'

The problem is the column can be 1 - 10 characters long.

+1  A: 
SELECT *
FROM yourTable
WHERE yourColumn NOT LIKE '%[^0-9]%'
LukeH
Ahhh the Carat. Thanks!
Shayne Judkins
Actually, the Carat is a "not" so it returns those rows that AREN'T all numbers.
Shayne Judkins
+1  A: 

Use the IsNumeric function:

select * from table where IsNumeric(column) = 1
Brad Wery
My interpretation of the question is that the column should only contain the characters `0` to `9`. The `ISNUMERIC` function will match if the column contains things like `1.75`, `-34`, `+96.28` etc.
LukeH
This works. Thanks!
Shayne Judkins