Preceding "N" character in SQL syntax

  • Hi,

    In some texts i find the character "N" preceding a string and was wondering what the significance was.

    For example in this code:

    SELECT CustomerID

    FROM Customer

    WHERE Country = N'Spain'

    Thanks,

    G

  • I think it has to do with using Unicode formatting.

  • Just to add to what tyson had to say,

    BOL

    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 by using a code page. Unicode constants do have a collation. This collation 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 by using 2 bytes per character instead of 1 byte per character for character data. For more information, see Using Unicode Data.

    Unicode string constants support enhanced collations.

    http://support.microsoft.com/kb/239530

    ---------------------------------------------------------------------------------

  • Cool thanks for the feedback, it's been bugging me for a while 😛

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply