Published on

December 12, 2012

Creating Database with Different Collation on SQL Server

Have you ever wondered if it is possible to have a database with a different collation on the same SQL Server instance? Well, the answer is yes! In this article, we will explore how to create databases with different collations and the benefits it can bring to your organization.

Collation refers to the rules that determine how string comparison and sorting is performed in a database. It affects how characters are compared and ordered, including whether or not case sensitivity is considered. By default, the collation of the server is fixed during installation and all databases on the system have to follow the same default collation.

However, there are scenarios where you may want to have databases with different collations. For example, let’s say you have an organization that deals with analytics and processes millions of records. Some clients may have case-sensitive tags on their server, while others may not care about case sensitivity. In such cases, having separate databases with different collations can be beneficial.

Traditionally, organizations would create separate instances of SQL Server for each collation requirement. However, this can lead to a complex and resource-intensive infrastructure. But now, with the ability to create databases with different collations on the same SQL Server instance, you can simplify your infrastructure and save resources.

Let’s take a look at an example. Suppose you want to create a case-sensitive database and a case-insensitive database on the same SQL Server instance. You can achieve this by running the following commands:

-- Create Case Sensitive Database
CREATE DATABASE CaseSensitive
COLLATE SQL_Latin1_General_CP1_CS_AS
GO
USE CaseSensitive
GO
SELECT *
FROM sys.types

-- Create Case Insensitive Database
CREATE DATABASE CaseInsensitive
COLLATE SQL_Latin1_General_CP1_CI_AS
GO
USE CaseInsensitive
GO
SELECT *
FROM sys.types

The above commands will create two different databases with case-sensitive and case-insensitive collations respectively. When you retrieve the default data types from each database, you will notice that they have different collations for their data types.

It is not only possible to set collation at the database level, but also at the instance level and even at the table column level. This gives you the flexibility to customize collation based on your specific requirements.

By creating databases with different collations on the same SQL Server instance, you can efficiently process and analyze data for clients with varying collation needs. This eliminates the need for separate instances and simplifies your infrastructure.

So, the next time you come across a situation where you need to handle different collations, consider creating separate databases on the same SQL Server instance. It’s a simple yet powerful solution that can greatly benefit your organization.

Click to rate this post!
[Total: 0 Average: 0]

Let's work together

Send us a message or book free introductory meeting with us using button below.