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 )
Note: CIS functional compensation performance considerations apply.

Parameters

Parameters

Parameter

Description

string

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

Returns

INT

Usage

For optimal performance, avoid using ISNUMERIC in predicates, where it is processed by the SQL Anywhere portion of the product and cannot take advantage of the performance features of Sybase IQ.

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

Standards and Compatibility

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

  • Sybase—Not supported by Adaptive Server Enterprise.