Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » System FunctionsRSS Feeds

ISNUMERIC Function

Posted By: Sarita Patel     Category: SQL Server     Views: 4457

This article explains about ISNUMERIC function in sql server with examples.

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
1

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.
  
Share: 

 
 
 

Didn't find what you were looking for? Find more on ISNUMERIC Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of ISNUMERIC Function is from United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!