The Prefix N conveys to the Sql Server that following literal string is of Unicode type. While storing Unicode (i.e. Japanese, Korean, Chinese etc) Characters in NChar, NVarchar or NText columns or variables we need to prefix the literal strings by letter N.
Below examples demonstrates the importance of the Prefix N for Unicode Characters in Sql Server and the issues which we may face if it is not used where it is required.
Double byte Characters are Stored/displayed as questions Marks if the Prefix N is not used
SELECT '名前' AS 'Double byte Characters without Prefix N' GO SELECT N'名前' AS 'Double byte Characters with Prefix N'
1 thought on “Why the prefix N is used for literal strings in Sql Server?”