naspinski
naspinski

Reputation: 34707

What is the 'N' when you are dealing with SQL such as (N'')

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

Upvotes: 3

Views: 203

Answers (3)

Tetsujin no Oni
Tetsujin no Oni

Reputation: 7375

N'' indicates a unicode String.

Upvotes: 1

John Woo
John Woo

Reputation: 263853

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.

Upvotes: 2

Yuck
Yuck

Reputation: 50855

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

Upvotes: 8

Related Questions