3

Just like in the question, not sure what the difference between '' and N'' in SQL.

1

3 Answers 3

8

It's shorthand for Nvarchar. Using that notation tells the parser to treat the following string data as nvarchar instead of the default varchar.

Example:

SELECT N'This is a test'; -- NVarChar data SELECT 'Test is a test'; -- VarChar data 
Sign up to request clarification or add additional context in comments.

2 Comments

It stands for "National" I believe.
@MartinSmith You're right - National Language Character. So weird.
2

N stores UNICODE data just like NVARCHAR and VARCHAR

An nvarchar column can store any Unicode data. A varchar column is restricted to an 8-bit codepage. Some people think that varchar should be used because it takes up less space. I believe this is not the correct answer. Codepage incompatabilities are a pain, and Unicode is the cure for codepage problems. With cheap disk and memory nowadays, there is really no reason to waste time mucking around with code pages anymore.

2 Comments

+1 A little off-topic, but I'm with you on using nvarchar by default. In some cases where I know I'm only storing something like a product code, or state abbreviation I'll fall back on varchar instead.
But as Celko says, you give someone a NVARCHAR column and eventually it will get a Buddhist sutra in Chinese Unicode.
1

N'' indicates a unicode String.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.