What does N' stands for in a SQL script ? (the one used before characters in insert script)

后端 未结 7 2398
孤城傲影
孤城傲影 2020-11-29 09:05

I generated an sql script like this,

INSERT [dbo].[TableName] ([Sno], [Name], [EmployeeId], [ProjectId], [Experience]) 
VALUES (1, N\'Dave\', N\'ESD157\', N\         


        
7条回答
  •  借酒劲吻你
    2020-11-29 09:33

    N is used to specify a unicode string.

    Here's a good discussion: Why do some SQL strings have an 'N' prefix?

    In your example N prefix is not required because ASCII characters (with value less than 128) map directly to unicode. However, if you wanted to insert a name that was not ASCII then the N prefix would be required.

    INSERT [dbo].[TableName] ([Sno], [Name], [EmployeeId], [ProjectId], [Experience]) 
    VALUES (1, N'Wāhi', 'ESD157', 'FD080', 7)
    

提交回复
热议问题