I have a SQL Server with several databases. I want for one of these databases to be case sensitive to names of variable and for others to not.
I need to change settings so I could run this script without errors
DECLARE @A int
DECLARE @a int
How can you change one database to be case sensitive (for its variable names), while allowing other databases on the instance to be case insensitive for variable names?
You need to change the server collation to case sensitive to get the behavior you want. Just changing the collation for the db is not enough.
The default collation of a SQL Server installation,
SQL_Latin1_General_CP1_CI_ASis not case sensitive.It sounds like you want to modify the collation of your server to one that is case-insensitive. Choose one with
_CS. The_CImeans “case insensitive“, and case-sensitive is_CS. Maybe you’ll wantLatin1_General_CS_AS.This is a great answer to a previous question on Changing SQL Server collation to case insensitive from case sensitive?.
From the SQL Server Books Online:
You can check your server collation using: