AS_NUMBER
functionsupportedCore SQL functionsCasts a VARIANT value to a fixed-point NUMBER value, with optional precision and scale. This function doesn’t cast floating-point values. AS_DECIMAL is a synonym for AS_NUMBER. The DECIMAL data type is synonymous with the NUMBER data type.
Syntax
supportedpartialnot supportednot scored
AS_DECIMAL( <variant_expr> [ , <precision> [ , <scale> ] ] )
AS_NUMBER( <variant_expr> [ , <precision> [ , <scale> ] ] )
Parameters
| Name | Required | Description |
|---|---|---|
variant_expr | required | An expression that evaluates to a value of type VARIANT. |
precision | required | The number of significant digits of the decimal number to store. The default is 38. |
scale | required | The number of significant digits after the decimal point. The default is 0. |
Returns
The function returns a value of type NUMBER or NULL: - If the type of the value in the variant_expr argument is DECIMAL or NUMBER, the function returns a value of type NUMBER. - If the type of the value in the variant_expr argument doesn’t match the type of the output value, the function returns NULL. - If the variant_expr argument is NULL, the function returns NULL.
Usage notes
- When reducing scale, this function rounds the result, which can cause out-of-range errors.