开发者

SQL Server syntax question

USE AdventureWorks;
GO
IF OBJECT_ID (N'dbo.AWBuildVersion开发者_Python百科', N'U') IS NOT NULL
DROP TABLE dbo.AWBuildVersion;
GO

Whats the N symbolize in N'dbo.AWBuildVersion' & N'U' ?


It's for Unicode. It's like an nvarchar or nchar SQL data type.

For more information, see this: You must precede all Unicode strings with a prefix N when you deal with Unicode string constants in SQL Server


This StackOverflow article has info on the subject. Basically the 'N' prefix denotes a Unicode string.


When dealing with Unicode string constants in SQL Server you must precede all Unicode strings with a capital letter N.

The "N" prefix stands for National Language in the SQL-92 standard, and must be uppercase.

If you do not prefix a Unicode string constant with N, SQL Server will convert it to the non-Unicode code page of the current db before it uses the string.

Sometimes people use N' out of habit, not when it is really necessary.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜