27

Is it possible to have a field in SQL Server that can store Chinese, Korean and European characters? My Chinese characters just become ?????

The datatype is NVARCHAR as well.

Dale K
  • 25,246
  • 15
  • 42
  • 71
Alessandro
  • 305
  • 2
  • 8
  • 22

2 Answers2

63

NVARCHAR is the proper type for this - it stores everything in a 2-byte Unicode.

What you need to pay attention to is when working with NVARCHAR fields in SQL Server Management Studio - you absolutely must use the N'....' prefix in that case!

If you use this:

INSERT INTO dbo.YourTable(NVarcharColumn)
    VALUES('Some Chinese text here')

then SSMS will temporarily convert the string literal you specify into VARCHAR (non-Unicode!) and thus you'll loose any Unicode-encoded characters.

However, if you use:

INSERT INTO dbo.YourTable(NVarcharColumn)
    VALUES(N'Some Chinese text here')

(note the N prefix before the string literal!) then SSMS will handle everything as Unicode all the time, and your Chinese or Korean (or other) special characters should be preserved.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • thanks for this, it doesn't seem to work though.. I have a feeling i'm missing some setting somewhere? – Alessandro Jan 20 '11 at 12:31
  • @Alessandro: are you trying to deal with data in SSMS, or from a client application? Also: which collation do you use on your server and on your database?? – marc_s Jan 20 '11 at 12:32
  • Via a coldfusion based web application.. Although i tried that script directly in SSMS SERVER COLLATION: SQL_Latin1_General_CP1_CI_AS DB COLLATION : SQL_Latin1_General_CP1_CI_AS – Alessandro Jan 21 '11 at 00:10
  • 1
    This fixed my issue! :D – jk1990 Oct 23 '18 at 08:48
  • 1
    I had set my column type to varchar and it displayed the char as ?, when i changed this to nvarchar it successfully stored Chinese, Japanese, and Korean characters. I did confirm that my database Collation was already set to SQL_Latin1_General_CP1_CI_AS – mknopf Feb 02 '20 at 20:51
0

Need to change the datatype of column to Nvarchar

insert into [dbo].[tablename] (columnname)values(N'日本')
Rajat Jaiswal
  • 645
  • 4
  • 15
babi
  • 41
  • 7