MS SQL Server UNICODE() Function

Sometimes you may need to determine the integer value of an Unicode character  in MS SQL Server. There is a function called UNICODE in MS SQL Server by which you can do this. UNICODE function returns the integer value, as defined by the Unicode standard, for the first character of the input expression.

Let’s see the function syntax:

UNICODE('ncharacter_expression');

In this syntax:

  • In this function there is one parameters of integer_expression.
  • Parameter ncharacter_expression is is an nchar or nvarchar expression..
  • Parameter ncharacter_expression be a constant, variable, or column.
  • Function returns an integer value of the first character of the ncharacter_expression as defined by the Unicode standard.

The following example uses NCHAR function to convert an integer  value to an Unicode character.

SELECT UNICODE('ক') AS UNICODE_Value, NCHAR(2453) AS UNICODE_Character; 

Here is the result set.

UNICODE_Value UNICODE_Character
2453

I have an another post MS SQL Server String Related Functions where you will learn about different string related functions of MS SQL Server.

In this tutorial, I have shown you how to convert an integer value to an Unicode character in MS SQL Server. Hope you have enjoyed the tutorial. If you want to get updated, like my facebook page http://www.facebook.com/freetechtrainer and stay connected.

Add a Comment