Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

NCHAR() Function in SQL Server

  • Last Updated : 30 Dec, 2020

NCHAR() function :
This function in SQL Server is used to return the Unicode character that is based on the number code.
For example, if the specified number is 65 then this function will return A.

Features :

  • This function is used to find the Unicode character of a given number.
  • This function accepts only positive numbers.
  • This function also accepts decimal numbers but returns the output of the number code before decimal sign.
  • This function always returns a character.
  • Here, the number code starts from 65.

Syntax :

NCHAR(number_code)

Parameter :
This method accepts a single parameter as given below :

  • number_code : Specified number code in the Unicode standard form in order to return the character for.

Returns :
It returns the Unicode character that is based on the number code.

Example-1 :
Getting the Unicode character of the number code 65.

SELECT NCHAR(65) AS NumberCodeToUnicode;

Output :

A

Here, the output is the first character as number code starts from 65.

Example-2 :
Getting the Unicode character of the specified decimal number 70.76.

SELECT NCHAR(70.76) AS NumberCodeToUnicode;

Output :

F

Here, only the number code 70 is considered and the numbers after decimal is ignored.

Example-3 :
Using NCHAR() function with a variable and getting the Unicode character of the specified number code 99.

DECLARE @number_code INT;  
SET @number_code = 99;  
SELECT NCHAR(@number_code);

Output :

c

Example-4 :
Getting the Unicode character of 125 which is the result of “250/2”.

SELECT NCHAR(250/2);

Output :

}

Example-5 :
Using NCHAR() function with a variable and getting the Unicode character of the specified float value “100.56”.

DECLARE @number_code Float;  
SET @number_code = 100.56;  
SELECT NCHAR(@number_code);

Output :

d

Application :
This function is used to return the Unicode character of a specified number code which is a positive number.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!