ISNUMERIC (T-SQL)

Determines whether an expression is a valid numeric type.

Syntax

ISNUMERIC(expression)

Arguments
expression
Is an expression to be evaluated.
Return Types

int

Remarks

ISNUMERIC returns 1 when the input expression evaluates to a valid integer, floating point number, money or decimal type; otherwise it returns 0. A return value of 1 guarantees that expression can be converted to one of these numeric types.

Examples
A. Use ISNUMERIC

This example returns 1 because the zip column contains valid numeric values.

USE pubs

SELECT ISNUMERIC(zip)

FROM authors

GO

  

B. Use ISNUMERIC and SUBSTRING

This example returns 0 for all titles in the titles table because none of the titles are valid numeric values.

USE pubs

GO

-- Because the title column is all character data, expect a result of 0

-- for the ISNUMERIC function.

SELECT SUBSTRING(title, 1, 15) type, price, ISNUMERIC(title)

FROM titles

GO

  

Here is the result set:

type            price                                 

--------------- -------------------------- -----------

The Busy Execut 19.99                      0          

Cooking with Co 11.95                      0          

You Can Combat  2.99                       0          

Straight Talk A 19.99                      0          

Silicon Valley  19.99                      0          

The Gourmet Mic 2.99                       0          

The Psychology  (null)                     0          

But Is It User  22.95                      0          

Secrets of Sili 20.00                      0          

Net Etiquette   (null)                     0          

Computer Phobic 21.59                      0          

Is Anger the En 10.95                      0          

Life Without Fe 7.00                       0          

Prolonged Data  19.99                      0          

Emotional Secur 7.99                       0          

Onions, Leeks,  20.95                      0          

Fifty Years in  11.95                      0          

Sushi, Anyone?  14.99                      0          

  

(18 row(s) affected)

  

See Also
Expressions System Functions


(c) 1988-98 Microsoft Corporation. All Rights Reserved.