本文共 790 字,大约阅读时间需要 2 分钟。
使用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.
但是这篇文章只是提到变量的数据是跟当前数据的,但是没有提到变量名称的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.()
综上可以得出SQL Server变量名称的Collcation是跟系统Master数据库,也就是Instance的Collation.
本文转自 lzf328 51CTO博客,原文链接: