Blog Pages

Check if an expression is numeric

IsNumeric:
select IsNumeric('0.2') -- return 1
select IsNumeric('asasa') -- return 0

http://msdn.microsoft.com/en-us/library/aa933213(v=sql.80).aspx

Note: parameter with value of NULL is not considered numeric, but parameter with value of empty string ('') will be converted to zero:

DECLARE @P int
SET @P = NULL
SELECT IsNumeric(@P) -- return 0
SET @P = ''
SELECT IsNumeric(@P) -- return 1
SELECT IsNumeric(NULL) -- return 0
SELECT IsNumeric('') -- return 0

No comments:

Post a Comment