Return the character corresponding to the given Unicode code point (alias of CHAR).
CHR(code)
## Overview Returns the single-character string whose Unicode code point equals the given integer. CHR is the common SQL name for the same function as CHAR and has identical semantics. Use it to generate arbitrary Unicode characters at runtime, including control characters such as tab and line feed. ## Behavior - Returns NULL when the input is NULL. - Accepts code points in the range [0, 0x10FFFF]. - For code point 0, returns a string containing a single NUL character. - Produces a string of length 1 in characters; byte length follows UTF-8 encoding rules. - Surrogate code points (0xD800 through 0xDFFF) have implementation-defined behaviour. - Negative values and values above 0x10FFFF raise an error. ## Compatibility - CHR and CHAR are interchangeable in DeltaForge. - Matches the common SQL convention for code-point conversion.
| Name | Type | Description |
|---|---|---|
code | Specifies the Unicode code point to convert. Must be a non-negative integer no greater than 0x10FFFF. |
-- Uppercase letter
SELECT CHR(65); -- 'A'
-- Lowercase z
SELECT CHR(122); -- 'z'
-- Tab character
SELECT CHR(9); -- horizontal tab
-- Unicode euro sign
SELECT CHR(8364); -- '€'
-- NULL propagates
SELECT CHR(CAST(NULL AS INT)); -- NULL
-- Use in a column expression to inject a separator
SELECT first_name || CHR(32) || last_name AS full_name
FROM retail.customers.profiles;