SQL CHR Function

Savigo
You organize your data. Now organize your savings.
Set savings goals, track your progress, and stay on course.
Get Savigo for iPhone 

The SQL CHR function accepts an ASCII code and returns the corresponding character. The CHR function is the opposite of the ASCII function.

Syntax #

CHR(ascii)

Most RDBMS such as Microsoft SQL Server, PostgreSQL, and Oracle uses the CHR function except MySQL uses the CHAR function which is equivalent to the CHR function.

Arguments #

ascii
The ASCII code that is in the range (1,255)

Return Type #

A character that represents the input ASCII code.

The function returns NULL if the input number is NULL.

If the input number is out of the range (1,255), the RDMBS may issue an error. This behavior is specific to the implementation of the CHR function in each RDBMS.

Examples #

The following statement returns characters of the ASCII code 65 and 97:

SELECT CHR(65), CHR(97);
 chr | chr
-----+-----
 A   | a
(1 row)

Was this helpful?