SQL Server 變數名稱的Collcation跟Instance還是跟當前DB?

來源:互聯網
上載者:User

使用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.

 

 

 

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.