Just like the subject stated:
what does the letter N
do in SQL like this:
SELECT P.ProductID,
S.SupplierID,
S.CompanyName
FROM Suppliers AS S JOIN Products AS P
ON (S.SupplierID = P.SupplierID)
WHERE P.UnitPrice > $10
AND S.CompanyName LIKE N'F%' -- what is the N for?
The "N" prefix stands for National Language in the SQL-92 standard, and is used for representing Unicode characters. In the current standard, it must be an upper case , which is what you will typically find implemented in mainstream products.
You may have seen Transact-SQL code that passes strings around using an N prefix. This denotes that the subsequent string is in Unicode (the N actually stands for National language character set). Which means that you are passing an NCHAR, NVARCHAR or NTEXT value, as opposed to CHAR, VARCHAR or TEXT.
n or N refers to Unicode... It means that the text in the variable uses Unicode. It also means that the size of the variable is 2 bytes per character instead of 1 byte per char like a varchar() variable would be.
The N just tells the parser that the string literal should be or is a double-byte (unicode) string. Since your parameter is already of type NVARCHAR the parser knows that what it is.
'N'
stands for representing unicode characters.
What this N does is tell the SQL Server that the data which is being passed in is uni-code and not character data. When using only the Latin character set this is not really needed. However if using characters which are not part of the basic Latin character set then the N is needed so that SQL knows that the data being given it is uni-code data.
Original source - http://itknowledgeexchange.techtarget.com/sql-server/whats-up-with-the-n-in-front-of-string-values/
N indicates the string is encoded in Unicode.
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