Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

CHAR() Function in SQL

  • Last Updated : 31 Aug, 2020

CHAR() :
This function could be used to find the character based on the ASCII (American Standard Code for Information Interchange) code. CHAR() function do not support multiple integers as arguments.

Syntax :

SELECT CHAR(code);

Note –
Parameter code is mandatory, code evaluates to an integer value from 0 to 255.

Example-1:

SELECT CHAR(65) AS Result;

Output :

Result
A

Example-2:

SELECT CHAR(165) AS Result;

Output :

Result
¥

Example-3:

SELECT CHAR(67, 255) AS Result;

Output :
The char function requires 1 argument(s). As shown in the above example, when multiple integers are provided, it gets an error.

Example-4:

SELECT CHAR(1000) AS Result;

Output :

Result
NULL

Note –
The above example results in NULL because the input is out of the range from 0 to 255.

Example-5:

SELECT 'Hello' + CHAR(10) + 'World' AS Result;

Output :

Result
Hello
World

Note –
In the above example, the CHAR(10) returns the new line, therefore, the second string is placed in the new line.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!