Char Function In Sql in SQL
? CHAR() Function in SQL
The CHAR() function returns the character represented by the ASCII code (or Unicode code) number you provide.
? Syntax
CHAR(integer_code)integer_code: An integer representing the ASCII/Unicode value.Returns a single character string.
? Examples
1. Get character for ASCII code 65
SELECT CHAR(65);-- Returns 'A'2. Get character for ASCII code 97
SELECT CHAR(97);-- Returns 'a'3. Concatenate characters using ASCII codes
SELECT CONCAT(CHAR(72), CHAR(105));-- Returns 'Hi'? Notes
CHAR()is available in many SQL dialects like MySQL, SQL Server, Oracle, etc.In some databases, the function can take multiple codes to return a string (e.g.,
CHAR(72, 105)returns'Hi'in SQL Server).Useful when you want to insert special or non-printable characters by their ASCII codes.
Want me to explain the opposite function ASCII() that returns the ASCII code of a character?