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.
Answers. Please ensure that you place "N" prefix while inserting UNICODE character or string into table with column as NVARCHAR type. Refer the below 2 Insert statements. The second one does not have capital N before the unicode string.
VARCHAR or NVARCHAR ? If it is VARCHAR with SQL_Latin1_General_CP1_CI_AS with , DB CAN NOT save Chinese. If it is NVARCHAR, DB can save Unicode include Chinese. OutSystems use NVARCHAR type, so it can handle Chinese well.
This works for me in SQL Server: CREATE TABLE #temp (a nvarchar(10) NOT NULL) INSERT #temp (a) VALUES(N'村'), (N'邨') SELECT * FROM #temp WHERE a = N'村'
Use braces to escape a string of characters or symbols. Everything within a set of braces in considered part of the escape sequence. When you use braces to escape a single character, the escaped character becomes a separate token in the query. Use the backslash character to escape a single character or symbol.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With