【鼠】庚子年乙酉月丁丑日 / 八月十六日
China's national day :: Thursday October 01, 2020

Microsoft SQL Server

There exsist a traditional Chinese and a simplified Chinese version of Microsofts SQL Server.

SQL Server 2000 is based on Unicode 2.0 (so it does not support GB18030)

Install
During the install one can choose the 'Collation designator' and the sort order for the chosen designator. For the Chinese language one can choose between Chinese_PRC, Chinese_PRC_stroke, Chinese_Taiwan_bopomofo, Chinese_Taiwan_stroke.

Usage
The mean trick is using N. Watch the following examples:

For each login one can specify the default language and database.
Use NVARCHAR instead of VARCHAR

Since SQL Server 7.0 and 2000 support both Unicode and non-Unicode data types, they require you to use the "N" prefix in front of Unicode string literals. Even though ADO is sending the query as Unicode text (since all COM automation components have Unicode interfaces), SQL Server believes that the string literal 'New Text' is supposed to be on the default system code page (CP_ACP) and it converts it to that code page. Then, upon inserting the text to an NTEXT column, SQL Server converts it back to Unicode using CP_ACP. This causes a slight performance hit for the query because of the two extra conversions, but it also causes strings to be corrupted if they are not on your server's default system code page. So the following code is WRONG :
UPDATE Table1 SET Col1 = 'New Text' WHERE id = 1000
and should be replaced by this one :
UPDATE Table1 SET Col1 = N'New Text' WHERE id = 1000

INF: Storing UTF-8 Date in SQL Server

[ < back ] - [ home ]