Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Possible Duplicate:
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?

like image 318
whatsupprogrammers Avatar asked Apr 08 '11 14:04

whatsupprogrammers


People also ask

How do I select only numeric values in a column in SQL?

In SQL Server, we can use the ISNUMERIC() function to return numeric values from a column. We can alternatively run a separate query to return all values that contain numeric data.

Can Nvarchar take numbers?

NVARCHAR is a locale-sensitive character data type that allows storing character data in variable-length fields as strings of single-byte or multibytemultibyteA variable-width encoding is a type of character encoding scheme in which codes of differing lengths are used to encode a character set (a repertoire of symbols) for representation, usually in a computer.https://en.wikipedia.org › wiki › Variable-width_encodingVariable-width encoding - Wikipedia letters, numbers, and other characters supported by the code set of the necessary database locale.


1 Answers

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
like image 57
Joe Stefanelli Avatar answered Oct 07 '22 06:10

Joe Stefanelli