IsNumeric Function in MSSQL

Hi, before knowing about this Numeric function i was done lot of queries write for to know the column is numeric or alpha.
This sql function is return 1 if its integer, if not it return zero.

Determines whether an expression is a valid numeric type.
Syntax

ISNUMERIC ( expression )

Arguments
expression

example:

DECLARE @table table(tempcol nvarchar(10))

INSERT INTO @table VALUES(‘1’)
INSERT INTO @table VALUES(‘2’)
INSERT INTO @table VALUES(‘3’)
INSERT INTO @table VALUES(‘A’)
INSERT INTO @table VALUES(’72Zs’)

SELECT tempcol, ISNUMERIC(tempcol) from @table

Usage:
SELECT * FROM @table WHERE ISNUMERIC(tempcol) = 1
SELECT * FROM @table WHERE ISNUMERIC(tempcol) <> 1

Output

sdf

Advertisements