DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
SITE SEARCH SQLUSA.com HEADLINES NEWS
SQL E/BOOKS   SQL 2014 PROGRAMMING   DOWNLOADS
SCRIPTS SQL 2005 SQL 2008 ARTICLES
SQL JOBS TWITTER FORMAT VIDEOS
How to handle Chinese, Japanese and Korean characters?

Execute the following T-SQL scripts in Microsoft SQL Server Management Studio Query Editor to illustrate the usage of Chinese, Japanese and Korean characters within an SQL Server database using unicode encoding.

-- Chinese, Japanese and Korean letters as UNICODE (2 bytes) characters

DECLARE @CHIuni nchar(1) = N''

SELECT CONVERT(binary(2),@CHIuni), UNICODE(@CHIuni)

-- 0xFD56    22269

--------------

USE AdventureWorks2008;
GO
-- SQL Chinese, Japanese and Korean characters - collations
-- Microsoft SQL Server unicode - nvarchar - 2 bytes per character
CREATE TABLE Sales.OrientalExpress (
  ID              INT    IDENTITY ( 1 , 1 ) PRIMARY KEY,
  FirstName       NVARCHAR(10),
  LastName        NVARCHAR(10),
  Address         NVARCHAR(50),
  City            NVARCHAR(20),
  State           NVARCHAR(2),
  Country         NVARCHAR(20),
  Zipcode         NVARCHAR(10),
  ModifiedDate    DATETIME default(getdate()))
GO
 
INSERT Sales.OrientalExpress(FirstName, LastName, Address, City,
State, Country, Zipcode)
SELECT N'零零四一二', N'零零六一零', N'一三二二四五 持質 室品社者手週習 五三',
N'店問冬道問堂冬', N'教弟', N'五九八六七', N'13663'
GO
 
SELECT * FROM Sales.OrientalExpress
GO
/* Results to TEXT
 
ID          FirstName  LastName   Address                                            City                 State Country              Zipcode    ModifiedDate
----------- ---------- ---------- -------------------------------------------------- -------------------- ----- -------------------- ---------- -----------------------
1           零零四一二      零零六一零      一三二二四五 持質 室品社者手週習 五三                               店問冬道問堂冬              教弟    五九八六七                13663      2009-03-02 16:16:43.890
*/
 
-- MSSQL unicode encoding of Chinese letters
SELECT            CONVERT(varbinary, left(FirstName,1)),
                  left(FirstName,1)
FROM Sales.OrientalExpress
GO
-- 0xF696  
 
-- Cleanup
DROP TABLE Sales.OrientalExpress
GO

------------
 
Related articles:

Why is sql server storing question mark characters instead of Japanese characters in NVarchar fields?

Chinese characters issue with T-SQL

 

Exam Prep 70-461
Exam 70-461
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE