Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » String FunctionsRSS Feeds

NCHAR Function

Posted By: Sarita Patel     Category: SQL Server     Views: 4458

This article explains NCHAR function of sql server with examples.

NCHAR function is used to convert integer value to Unicode character specified by Unicode Standards.


Syntax of NCHAR Function :

NCHAR (integer_expression)

integer_expression can be any positive number from 0 to 65535. If you specify number other than this range then it returns NULL.  

Return type of NCHAR function is nchar(1).


Examples of NCHAR Function :

Example 1 : Use of NCHAR function in select clause

SELECT NCHAR(69)

Output
E

Above example returns unicode character value 'E' for integer value 69.


Example 2 : Use of NCHAR function to display unicode value for field value of table.

SELECT NCHAR(UnitPrice) AS 'UnitPrice'    
FROM   Invoices

Output
UnitPrice
C
'

7
(
|

Above example displays unicode character value for unitprice field of invoices table.



Example 3 : Use of NCHAR function in where clause

SELECT CustomerName
FROM   Invoices
WHERE  NCHAR(ProductID) = '<'

Output
CustomerName
Ernst Handel
Romero y tomillo
Bottom-Dollar Markets
QUICK-Stop
LINO-Delicateses

Above example compares unicode of productid with '<' sign and displays all records having productid unicode as '<'.
 
  
Share: 

 
 
 

Didn't find what you were looking for? Find more on NCHAR Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of NCHAR Function is from United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!