ISNUMERIC Function [Miscellaneous]

Tests whether a string argument can be converted to a numeric.

If a conversion is possible, the function returns 1; otherwise, it returns 0. If the argument is null, 0 is returned.

Syntax

ISNUMERICstring )

Parameters

Parameter

Description

string

The string to be analyzed to determine whether the string represents a valid numeric value

Returns

INT

Standards and Compatibility

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Supported by Adaptive Server 15.0.1 and later.

Example

The following example tests whether the height_in_cms column holds valid numeric data, returning invalid numeric data as NULL, and valid numeric data in int format.

data height_in_cms
------------------------
asde
asde
180
156
select case
   when isnumeric(height_in_cms)=0
   then NULL
   else cast(height_in_cms as int) 
   end
from MyData