In my recent Office Hours, I received a question on how to determine the case sensitivity of the database.
The quick answer to this is to identify the collation of the database and check the properties of the collation. I have previously written how one can identify database collation. Once you have figured out the collation of the database, you can put that in the WHERE condition of the following T-SQL and then check the case sensitivity from the description.
SELECT * FROM fn_helpcollations()
The method shown above is the most recommended method and I suggest using the same.
When I was a young DBA, I did not have the patience to follow the above method. I used to do something very simple.
SELECT 1 WHERE 'SQL' = 'sql'
If the above query returns me the result, it means that the database is case-insensitive. Please note that by no means do I suggest using this method; I really recommend using the method fn_helpcollations().
Another interesting suggestion was from Dave Dustin who is SQL Server MVP from New Zealand. He has provided the following script:
SELECT 1 FROM sys.Databases WHERE name='<databasename>' AND (collation_name LIKE '%CS%' OR collation_name LIKE '%BIN%')
Insert your database name in the WHERE clause. If the query returns any result, it means the database is case-sensitive.
It’s interesting to see that one simple question can result to three interesting ways to know the answer. Do you know any other method to know the database case sensitivity? Please share it here and I will post it with due credit.
Reference: Pinal Dave (http://blog.SQLAuthority.com)