Logo

SQL Server VALUE Function

Updated 2023-11-10 16:11:04.090000

Description

Use the scalar function VALUE to convert a text string that represents a number to a number.

Syntax

SELECT [westclintech].[wct].[VALUE] (
   <@Numval, nvarchar(4000),>)

Arguments

@Numval

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

Return Type

float

Remarks

The VALUE function will convert any string where ISNUMERIC evaluates to TRUE

Examples

Select wct.VALUE('50%');

This produces the following result.

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

This produces the following result.

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