What is =N'' xxx '' ?

  • Hi - in the following

     

    if not exists (select * from dbo.sysusers where name = N'A01' and uid < 16382)

     EXEC sp_grantdbaccess N'A01', N'A01'

    GO

     

    what is the N in N'A01' doing ?

  • It converts to unicode.

  • N'A01' tells SQL Server to treat the contents of the string, in this case A01, as Unicode.  If you look at the sysusers.name column, it is of data type SysName.  SysName is a unicode datatype equal to nvarchar(128).

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • John - thanks for that.

     

    (Where are you supposed to find that out for yourself?!)

  • Books online / Unicode / Constants.

     

    By you pretty much need to know what you are searching for in this case .

  • The key to remember is that Unicode takes two bytes per character so all your Unicode fields take twice as much space (and you can only get half as many in a record).  Only use it if you need to handle Unicode characters.

     

  • Good point... but I think the poster was reffering to some generated code (most likely EM)!

  • You're right - but I thought the warning wouldn't go amiss.  It looked as if he wasn't aware of this feature so doesn't hurt to pre-empt any future issues. 🙂

  • Totally with you on this one .

Viewing 9 posts - 1 through 8 (of 8 total)

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