Skip to main content

CHAR

The CHAR() function returns the character corresponding to the specified ASCII code.

See also:
[SELECT]


note

When using StackQL with a PostgreSQL backend, the equivalent function is CHR().

Syntax

SELECT CHAR(ascii_code) FROM <multipartIdentifier>;

The CHAR() function returns the character associated with the given ASCII code.

Arguments

ascii_code
An integer representing the ASCII code of the desired character.

Return Value(s)

Returns a single-character string corresponding to the specified ASCII code.


Common ASCII Codes

CharacterDescriptionASCII CodeUsage Example
\nNewline10CHAR(10)
'Single Quote39CHAR(39)
"Double Quote34CHAR(34)
(space)Space32CHAR(32)
:Colon58CHAR(58)
;Semicolon59CHAR(59)
\tHorizontal Tab9CHAR(9)
\rCarriage Return13CHAR(13)
\bBackspace8CHAR(8)
\fForm Feed12CHAR(12)

Examples

Concatenate Strings with Special Characters

To concatenate strings with a newline character between them:

SELECT 
'/* ' || displayName || ' */' || CHAR(10) || 'DELETE FROM databricks_account.iam.users WHERE account_id = ' || CHAR(39) || account_id || CHAR(39) || ' AND id = ' || CHAR(39) || id || CHAR(39)
FROM
databricks_account.iam.users
where account_id = 'abcd1234-1234-5678-90ab-abcdef123456'
AND active = false;

Result:

He said "Hello" and left.