CAST(…expr… AS …type…)
…type…(…expr…)
t1 -> t2
Any type can be cast into any other one. For instance, strings can be parsed as numbers or numbers printed as strings. Some conversion makes no sense and might lead to surprising results.
The result is the requested type, forced nullable if the expression is nullable. See FORCE to cast away nullability.
expression | evaluates to |
---|---|
CAST(PI AS U8) | 3 |
CAST(PI AS STRING) | "3.14159265359" |