ISNUMERIC function is used to check an expression is a valid numeric type or not.
ISNUMERIC function returns 1 when the expression evaluates to a valid integer, float, decimal or money data type otherwise it returns 0.
Syntax of ISNUMERIC Function :
ISNUMERIC (expression)
expression is any valid sql server expression to be evaluated.
Return type of ISNUMERIC function is an integer.
Examples of ISNUMERIC Function :
Example 1 : Use of ISNUMERIC function in select clause
SELECT ISNUMERIC ('123')
SELECT ISNUMERIC (123)
Output
Both above example returns 1 because 1st statement has an argument string '123' which can be converted to valid numeric type and 2nd statement has an argument which is an integer value.
Example 2 : Use of ISNUMERIC function to check column value of a table in select clause
SELECT ContactName, PostalCode, ISNUMERIC(PostalCode) AS ValidNumeric
FROM Customers
Output
ContactName PostalCode ValidNumeric
Maria Anders 12209 1
Ana Trujillo 05021 1
Antonio Moreno 05023 1
Thomas Hardy WA1 1DP 0
Christina Berglund S-958 22 0
Hanna Moos 68306 1
Above example returns 1 where postalcode is valid numeric data or can be converted in numeric type otherwise it returns 0.