I just inherited a project that has code similar to the following (rather simple) example:
DECLARE @Demo TABLE
(
Quantity INT,
Symbol NVARCHAR(10)
)
INSERT INTO @Demo (Quantity, Symbol)
SELECT 127, N'IBM'
My interest is with the N
before the string literal.
I understand that the prefix N
is to specify encoding (in this case, Unicode). But since the select is just for inserting into a field that is clearly already Unicode, wouldn't this value be automatically upcast?
I've run the code without the N
and it appears to work, but am I missing something that the previous programmer intended? Or was the N
an oversight on his/her part?
I expect behavior similar to when I pass an int
to a decimal
field (auto-upcast). Can I get rid of those N
s?