开发者

how to select only the int values in a column that is nvarchar [duplicate]

开发者 https://www.devze.com 2023-02-23 05:52 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplic开发者_Go百科ate: CAST and IsNumeric
This question already has answers here: Closed 11 years ago.

Possible Duplic开发者_Go百科ate:

CAST and IsNumeric

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


Adding the '.0e0' to the end of the column in the ISNUMERIC check will ensure that only integers will be found.

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


You check for isnumeric:

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

精彩评论

暂无评论...
验证码 换一张
取 消