Here, I am going to explain some basics of UNICODE data types and functions in SQL Server. UNICODE is a uniform character encoding standard. A UNICODE character uses multiple bytes to store the data in the database. This means that using UNICODE it is possible to process characters of various writing systems in one document. This could be useful if you're working with an international character set (for example different languages). So let's have a look at a practical example of how to use UNICODE data types and functions in SQL Server 2012. The example is developed in SQL Server 2012 using the SQL Server Management Studio.
SQL Server supports three UNICODE data types; they are:
- NCHAR
- NVARCHAR
- NTEXT
NCHAR in SQL Server
The NCHAR data type specifies the string length and must be a value from 1 through 4,000. The NCHAR data type stores fixed length UNICODE characters. It should be used for the definition of alphanumeric columns, where all data values are approximately the same length.
Example
- DECLARE @Ncharlength NCHAR(4001)
- Select @Ncharlength

NVARCHAR in SQL Server
The NVARCHAR data type can also store 4000 characters. The NVARCHAR data type stores UNICODE characters of varying length. It should be used for the definition of alphanumeric columns, where the values vary dramatically in size.
NTEXT in SQL Server
The ISO synonym for "ntext" is "national text".NTEXT stores large character data (with more than 4000 characters).
UNICODE Functions in SQL Server
There are two functions related to UNICODE.
- Unicode('char_expression')
- Nchar(int_expression)
UNICODE Function
The UNICODE function works just like ASCII, except it accepts the UNICODE character value as input. This could be useful if you're working with international character sets. The function UNICODE returns the integer value for the first character of the UNICODE character string char_expression.
Syntax
UNICODE('ncharacter_expression')
Example


Dinesh kinagePosted Sep 29, 2019, 2:52 AM
How to pass N dynamically variable not like that Declare @name nvarchar(40)=N'???' Declare @name nvarchar(40)='???' Select UNICODE (@name) as Integervalue, NCHAR (unicode(@name)) as 'Unicode'
Binod KumarPosted Jul 15, 2019, 2:19 AM
GOOD ONE SIR