Insert Unicode Characters Without Changing Collation

2011-02-16


Normally, in western country, when you create a SQL Server database, your database collation is default by 'SQL_Latin1_General_CP1_CI_AS', If you want to use Unicode for data table column, you use nvarchar or nchar, Do not use varchar / char because they are only for Non-Unicode characters. This is the 1st condition we should have for Unicode.

The second, you can use specified Collation for your database, for example, for Chinese, you can use Collation 'Chinese_PRC_CI_AS', then whatever you insert into database, the result always is in Unicode.

But, our question is: How to Insert Unicode Characters Without Changing Collation ?

Why we have this question because most of time we can not change existing database, and, we should have a way to insert unicode characters if we can not change database collation.

Here it is: When you insert data, you should use 'N' for any string.

Here is the example:


INSERT INTO [USER_CONFIG]
           ([FullName], [UserName] , [UserPassword])
     VALUES
           (N'John', N'My Name'</font>, 1234)