I found something weird in this query
SELECT *
FROM t1
WHERE t1.country = N'USA';
why N Letter is used ?
The N stands for "National Character" and it means that the content of the string is Unicode.
You should be using Unicode (nchar/nvarchar
) whenever you might come across proper names or other entities that can contain characters outside of the default ASCII character set. If you don't surround such strings with the N
prefix, you will lose data. For example:
SELECT N'ук ферт хер', 'ук ферт хер';
Results:
----------- -----------
ук ферт хер ?? ???? ???
You should also be sure to use the N prefix in your WHERE or other clauses against n(var)char columns. When you don't use the N prefix, you could suffer serious performance issues due to implicit conversion.
N is for the compatibility of a character. Used for representing unicode characters.
It declares the string as nvarchar data type, instead of varchar, and the difference is that varchar column only stores an 8-bit codepage and a nvarchar column can store any Unicode data