is putting N in front of strings in scripts considered a "best practice"?
Posted
by jcollum
on Stack Overflow
See other posts from Stack Overflow
or by jcollum
Published on 2010-04-26T19:19:25Z
Indexed on
2010/04/26
19:23 UTC
Read the original article
Hit count: 219
sql
|sql-server
Let's say I have a table that has a varchar field. If I do an insert like this:
INSERT MyTable
SELECT N'the string goes here'
Is there any fundamental difference between that and:
INSERT MyTable
SELECT 'the string goes here'
My understanding was that you'd only have a problem if the string contained a Unicode character and the target column wasn't unicode. Other than that, SQL deals with it just fine and converts the string with the N'' into a varchar field (basically ignores the N).
I was under the impression that N in front of strings was a good practice, but I'm unable to find any discussion of it that I'd consider definitive.
Title may need improvement, feel free.
© Stack Overflow or respective owner