>  기사  >  데이터 베이스  >  SQL Server 变量名称的Collcation跟Instance还是跟当前DB?

SQL Server 变量名称的Collcation跟Instance还是跟当前DB?

WBOY
WBOY원래의
2016-06-07 15:44:141133검색

使用SQL Server变量的时候碰到变量名称大小写的问题: 当前数据库是大小写不敏感的,但是声明变量之后发现变量名称是大小写敏感的。一直认为SQL Server的变量名称的Collcation是跟当前数据库的,在MSDN: You cannot specify a collation for character vari

使用SQL Server变量的时候碰到变量名称大小写的问题:

 

SQL Server 变量名称的Collcation跟Instance还是跟当前DB?

SQL Server 变量名称的Collcation跟Instance还是跟当前DB?

 

当前数据库是大小写不敏感的,但是声明变量之后发现变量名称是大小写敏感的。一直认为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.

 

 

 

 

 

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.