开发者

SQL: Whats the difference between ... WHERE O.type = N'U' ... and ... WHERE O.type = 'U'

开发者 https://www.devze.com 2023-01-14 13:12 出处:网络
Today I came across an SQL statement that contains an element I\'ve never seen. Maybe someone can elaborate? This SQL is from a stored procedure in Sybase ASE 15

Today I came across an SQL statement that contains an element I've never seen. Maybe someone can elaborate? This SQL is from a stored procedure in Sybase ASE 15

SELECT O.id, OWNER = U.name, O.name, O.type FROM xxx.dbo.sysobjects O LEF开发者_如何学编程T JOIN xxx.dbo.sysusers U ON O.uid = U.uid WHERE (O.type = N'U' OR O.type = N'S' OR O.type = N'V') ORDER BY O.name

Running

SELECT O.id, OWNER = U.name, O.name, O.type FROM xxx.dbo.sysobjects O LEFT JOIN xxx.dbo.sysusers U ON O.uid = U.uid WHERE (O.type = 'U' OR O.type = 'S' OR O.type = 'V') ORDER BY O.name

gives the same result as the SQL above.

What does the N infront of the parameter do?


The N ensures the value stated is treated as unicode


It's a "nationalized" (Unicode) string.


The N stands for National - the N converts the VARCHAR to a NVARCHAR, which is used to store unicode data, which is used to store multilingual data in your database tables.

0

精彩评论

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