I recently came across an organization who had very interesting infrastructure setup. Their business domains is analytics. They process millions of the records and how many clients who have case sensitive tags on their server which they want to measure. However, there are many places they do not want to care about case sensitivity. They had peta bytes of the data on their server. When I saw their servers – I noticed that every SQL Server had two instances installed – 1) Case Sensitive and 2) Case Insensitive. After a while I asked them why do they have two instances on the same server with almost similar data – one with case sensitive and another with case insensitive instances.
The answer I received was very interesting – they wanted both the data processed individually even though they are separate and in that they have two different instances on the same server. The organization was dealing with hundreds of the servers and instances, I could not digest that they have two similar instances. When I asked if they ever considered to create two separate database on the same instances instead of creating a new instance for just case sensitivity. The answer was something I did not expect at all. Here is what their Sr. DBA answered.
“Can we create a database with different collations on the same SQL Server Instance? We thought, the collation of the server is fixed during the installation and all the database on the system have to follow the same default collation.”
I took a deep breath and in their development database I ran following commands.
-- Create Case Sensitive Database CREATE DATABASE CaseSensitive COLLATE SQL_Latin1_General_CP1_CS_AS GO USE CaseSensitive GO SELECT * FROM sys.types GO -- Create Case In-Sensitive Database CREATE DATABASE CaseInSensitive COLLATE SQL_Latin1_General_CP1_CI_AS GO USE CaseInSensitive GO SELECT * FROM sys.types GO
The above command will create two different databases with Case-Sensitive and Case -Insensitive collations. When we retrieved the default datatypes from the database we can see that they have different collation for their data types. It is absolutely possible to database with a different collation on a same SQL Server Instance. It is also possible to create an individual column in a table with different collations from server instance and database as well.
Collation can be set at SQL Server instance Level, Database Level as well as Table Column Level.
Reference: Pinal Dave (http://blog.sqlauthority.com)