Showing posts with label Encoding. Show all posts
Showing posts with label Encoding. Show all posts

Monday, July 13, 2009

SQL Server with Unicode / Khmer Unicode characters

To be notice MS SQL supports only UCS-2 encoding so do not have encoding with UTF-8 as we expected as MySQL or some other database server as well. This means that you can't use UTF-8 character encoding with Microsoft SQL Server:

Here after I type Khmer Unicode and execute the query, I got question marks instead of characters:

So if you need to store national characters in Microsoft SQL Server - please consider using a national character encoding (U+1780 to U+17FF in Unicode/ISO10646 for Khmer Unicode characters, for example). Change data types:
  • varchar to nvarchar
  • text to ntext
  • char to nchar
Here is the example since I created a table and insert data:
1. Create database (mtr_db) as normally (default setting)

2. Create table (tblunicode) with two fields (id/name) but
name - data type nvarchar(MAX)


3. Insert Khmer Unicode and execute we got it as we typed!
Good luck!