Logo

ISNUMERIC

Updated 2023-11-10 19:47:21.300000

Syntax

SELECT [westclintech].[wct].[ISNUMERIC] (
   <@Text, nvarchar(4000),>)

Description

Use the scalar function ISNUMERIC to determine if a value is numeric.

Arguments

@Text

is the text to be evaluated. The @Text argument can be of data types that are implicitly convertible to nvarchar or ntext.

Return Type

bit

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 indicates that expression can be converted to at least one of the numeric types.

ISNUMERIC evaluates fractions as TRUE.

ISNUMERIC evaluates numbers with leading, trailing, or embedded spaces as TRUE.

ISNUMERIC evaluates numbers ending with the percent grammalogue (%)as TRUE.

ISNUMERIC evaluates the decimal point and SPACE or SPACE and the decimal point as FALSE.

Any string that ISNUMERIC evaluates as TRUE, can be converted to a floating point number using the VALUE function.

Examples

select wct.isnumeric('3/8');

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"1"}]}
select wct.isnumeric('50.0%');

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"1"}]}
select wct.isnumeric('3.14159 26535 89793 38462');

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"1"}]}
select wct.isnumeric('-5 3/4');

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"1"}]}
select wct.isnumeric('.');

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"0"}]}