- Categories:
AS_CHAR , AS_VARCHAR¶
Casts a VARIANT value to a VARCHAR value. This function only converts CHAR and VARCHAR values.
The AS_CHAR and AS_VARCHAR functions are synonymous.
The CHAR data type is synonymous with the VARCHAR data type, except for its default length.
- See also:
Syntax¶
Arguments¶
variant_exprAn expression that evaluates to a value of type VARIANT.
Returns¶
The function returns a value of type VARCHAR or NULL:
If the type of the value in the
variant_exprargument is CHAR or VARCHAR, the function returns a value of type VARCHAR.
If the type of the value in the
variant_exprargument doesn’t match the type of the output value, the function returns NULL.If the
variant_exprargument is NULL, the function returns NULL.
Examples¶
Create a table and load data into it:
Use the AS_VARCHAR function in a query to cast a VARIANT value to a VARCHAR value: