SQL SERVER – Creating Database with Different Collation on Server

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.

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.

If columns can have different collations, then index columns keys can also I suppose? And then are dual databases even necessary? I guess we’d have to see the usage, but it seems to me the same data in two columns of a table with different indexes on the two columns would serve the different orderings needed with one table of data!

So what do you do with the tempdb? In cases when I have had different collated databases in the same instance, those that didn’t match the tempdb had problems with comparisons and other operations that involve the tempdb. I had to add COLLATE specifics to the WHERE clauses. This is not always possible with vendor databases.

Community Initiatives

About Pinal Dave

Pinal Dave is a Pluralsight Developer Evangelist. He has authored 11 SQL Server database books, 17 Pluralsight courses and have written over 3200 articles on the database technology on his blog at a http://blog.sqlauthority.com. Along with 11+ years of hands on experience he holds a Masters of Science degree and a number of certifications, including MCTS, MCDBA and MCAD (.NET). His past work experiences include Technology Evangelist at Microsoft and Sr. Consultant at SolidQ. Follow @pinaldave
Send Author Pinal Dave
an email at pinal@sqlauthority.com

Email Subscription

Enter your email address to subscribe to this blog and receive notifications of new posts by email.