Assuming ProductId is INT column, what is the difference between writing 3 and N'3'?
They both work fine.
INSERT INTO dbo.Products (ProductId, Name)开发者_如何转开发 VALUES (3,'Product3')
INSERT INTO dbo.Products (ProductId, Name) VALUES (N'3','Product3')
N'3' is a nvarchar type, where 3 is an int. If you're using nvarchar you're asking the parser to perform implicit conversion. In this case it works fine but in others you may run into casting problems.
When SQL Server encounters N'', it will treat the string as an NVARCHAR instead of VARCHAR. NVARCHAR fields are unicode.
The reason N'3' still works for you is because it is converting it to NVARCHAR, and then doing an implicit conversion to INT.
加载中,请稍侯......
精彩评论