Reputation: 861
I'm using Microsoft SQL Server 2017 (RTM) - 14.0.1000.169 (X64)
Aug 22 2017 17:04:49
Copyright (C) 2017 Microsoft Corporation
Developer Edition (64-bit) on Windows Server 2012 R2 Standard Evaluation 6.3 <X64> (Build 9600: ) (Hypervisor)
When i do: INSERT INTO MYTABLE(COLNAME) VALUES ('Қазақстан')
it inserts question marks ?????????
instead of actual string. My column type is NVARCHAR(255)
. If i insert N
character before my value like this: ...(N'Қазақстан')
it will be persisted properly. Is it the only way to insert non-ASCII characters or should i change something else?
Thanks!
Upvotes: 0
Views: 1102
Reputation: 14928
The answer to your question is Yes, you should use N
From Docs
When prefixing a string constant with the letter N, the implicit conversion will result in a UCS-2 or UTF-16 string if the constant to convert does not exceed the max length for the nvarchar string data type (4,000). Otherwise, the implicit conversion will result in a large-value nvarchar(max).
So if you don't use N
then SQL Server will treate it as VARCHAR
(non unicode).
Using the N
will convert the string to unicode string.
Upvotes: 4