Reputation: 28572
Below is my code sample.
DECLARE @a TABLE (a VARCHAR(20));
INSERT @a
(a)
VALUES ('中');
SELECT *
FROM @a;
I'm using SQL Server Management Studio to run it. My question is, why I can insert non-ascii characters into VARCHAR column and correctly get it back? As I understand, VARCHAR type is only for ascii characters and the NVARCHAR is for unicode characters. Anyone can help to explain it please? I'm on Windows 7 with SQL Server 2014 developer edition.
Upvotes: 1
Views: 1921
Reputation: 2912
The codepage used to store the varchar data varies by DB collation.
https://msdn.microsoft.com/en-us/library/ms189617.aspx
Varchar is 8 bits, so you may have a different collation, or you may have gotten lucky on where your character falls on the code set
Upvotes: 2
Reputation: 5672
You can find the ASCII
and Extended ASCII
characters below.
ASCII
Extended ASCII
I don't believe '中' is an ASCII character.
Upvotes: 0