N'' in SQL Server

HardCode
10-15-2004, 01:14 PM
What does the N in front of a single quote signify?

IF (SELECT COUNT(*)
FROM msdb.dbo.syscategories
WHERE name = N'Database Maintenance') < 1

jjStinger72
10-15-2004, 03:02 PM
just a guess here, but i think it means "treat the String as Unicode". it goes to say that the nNhar and nVarChar are the unicode version of the char and varchar data types... the N would mean the same?? i definatly recall seeing something on this in the "books on line" that installs with the Enterprise tools, but it's been a while.

HardCode
10-15-2004, 03:05 PM
I looked there, but there is nothing in the index for N :(

jjStinger72
10-15-2004, 04:05 PM
I looked there, but there is nothing in the index for N :(

...sorry for the delay, i had to install SQL Client tools (didnt have it on this pc)

after searching through the Books Online for a bit, i came across this Transact SQL Reference for Constants...


A constant, also known as a literal or a scalar value, is a symbol that represents a specific data value. The format of a constant depends on the data type of the value it represents.

Character string constants

Character string constants are enclosed in single quotation marks and include alphanumeric characters (...

Unicode strings

Unicode strings have a format similar to character strings but are preceded by an N identifier (N stands for National Language in the SQL-92 standard). The N prefix must be uppercase. For example, 'Michél' is a character constant while N'Michél' is a Unicode constant. Unicode constants are interpreted as Unicode data, and are not evaluated using a code page. Unicode constants do have a collation, which primarily controls comparisons and case sensitivity. Unicode constants are assigned the default collation of the current database, unless the COLLATE clause is used to specify a collation. Unicode data is stored using two bytes per character, as opposed to one byte per character for character data. For more information, see Using Unicode Data.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum