ISNUMERIC function [Miscellaneous]

Function

Tests if a string argument can be converted to a numeric. If a conversion is possible, the function returns 1; otherwise, 0 is returned. If the argument is null, 0 is returned.

Syntax

ISNUMERIC ( string )

Parameters

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

Usage

For optimal performance, avoid using ISNUMERIC in predicates, where it is processed by the Adaptive Server 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