Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2003
    Posts
    22

    Question Unanswered: Dumb Question - Significance of N

    I know this is a stupid question, but I just can't find the proper explanation. I often see the letter N preceding a parameter when executing a stored procedure (ie. exec sp_xxx @parm = N'test'). What is the significance of the N and when should it be used?

    Thanks,
    Roby2222

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    It indicates that the data type of the parameter in question is NCHAR, NVARCHAR, or NTEXT, as opposed to CHAR, VARCHAR, or TEXT.
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    The N prefix on a string constant forces the string to be interpreted as unicode (16 bit) characters instead of OEM (8 bit) characters.

    -PatP

  4. #4
    Join Date
    Feb 2004
    Posts
    193
    That is not a dumb question at all. I have wondered that myself as I have seen it in IF EXISTS statements to begin a stored procedure script and so forth, ie:

    if exists (select * from dbo.sysobjects
    where id = object_id( N'[dbo].[tablename]')
    and OBJECTPROPERTY(id, N'IsUserTable') = 1)

    Thanks for the question.

    ddave

  5. #5
    Join Date
    Dec 2003
    Posts
    22

    Thanks

    Thanks for the info. Makes sense...

    Roby2222

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •