使用sql server变量的时候碰到变量名称大小写的问题: 当前数据库是大小写不敏感的,但是声明变量之后发现变量名称是大小写敏感的。一直认为sql server的变量名称的collcation是跟当前数据库的,在msdn: you cannot specify a collation for character vari
使用sql server变量的时候碰到变量名称大小写的问题:
当前数据库是大小写不敏感的,但是声明变量之后发现变量名称是大小写敏感的。一直认为sql server的变量名称的collcation是跟当前数据库的,在msdn:
you cannot specify a collation for character variables and parameters; they are always created with the default collation of the database.http://msdn.microsoft.com/en-us/library/aa174903(v=sql.80).aspx
但是这篇文章只是提到变量的数据是跟当前数据的,但是没有提到变量名称的collcation. 之后在msdn论坛发现有相同的问题,微软工程师的回复如下:
please note that variable collation is based on the server side (master db) collation, not on the user database collation.
for example if you have a case sensitive server, but a case-insensitive user database the variable declarions are case sensitive, since they live in memory of the server, and that uses the server collation.(http://social.msdn.microsoft.com/forums/en-us/vstsdb/thread/0d833fab-2b32-4b98-a3ab-cdf8c743e5e0)
综上可以得出sql server变量名称的collcation是跟系统master数据库,也就是instance的collation.