CHAR() Function in SQL

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

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.