SQL Server检查是否区分大小写? [英] SQL Server check case-sensitivity?
问题描述
如何检查SQL Server中的数据库是否区分大小写?我以前一直在运行查询:
How can I check to see if a database in SQL Server is case-sensitive? I have previously been running the query:
SELECT CASE WHEN 'A' = 'a' THEN 'NOT CASE SENSITIVE' ELSE 'CASE SENSITIVE' END
但是我正在寻找其他方式,因为这实际上在过去给了我很多问题
But I am looking for other ways as this has actually given me issues in the past.
编辑-更多信息:
现有产品具有许多预写的存储过程。在存储过程中, @test!= @TEST
取决于服务器本身的敏感性。因此,我要寻找的是检查服务器灵敏度的最佳方法。
Edit - A little more info:
An existing product has many pre-written stored procedures. In a stored procedure @test != @TEST
depending on the sensitivity of the server itself. So what I'm looking for is the best way to check the server for its sensitivity.
推荐答案
可以在各种情况下设置排序规则级别:
Collation can be set at various levels:
- 服务器
- 数据库
- 列
因此,您可以在不区分大小写的数据库中包含一个区分大小写的列。我还没有遇到过可以针对单个数据列的大小写敏感性进行业务案例分析的情况,但是我想可能会存在。
So you could have a Case Sensitive Column in a Case Insensitive database. I have not yet come across a situation where a business case could be made for case sensitivity of a single column of data, but I suppose there could be.
检查服务器排序规则
SELECT SERVERPROPERTY('COLLATION')
检查数据库排序规则
SELECT DATABASEPROPERTYEX('AdventureWorks', 'Collation') SQLCollation;
检查列排序规则
select table_name, column_name, collation_name
from INFORMATION_SCHEMA.COLUMNS
where table_name = @table_name
这篇关于SQL Server检查是否区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!