How to select only int values ​​in a column that is nvarchar

Possible duplicate:
CAST and IsNumeric

I have a database column that is nvarchar, but I only want to get database rows that have integers in this column field, is this possible?

+5
source share
2 answers

Adding ".0e0" to the end of the column in the ISNUMERIC check ensures that only integers are found.

SELECT *
    FROM YourTable
    WHERE ISNUMERIC(YourColumn + '.0e0') = 1
+13
source

You check the isnumeric value:

select evalcolumn from table where isnumeric(evalcolumn) = 1
0
source

All Articles