Open In App

NCHAR() Function in SQL Server

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 :



Syntax :

NCHAR(number_code)

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



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.

Article Tags :
SQL