What is the use of Collation in SQL SERVER?
SQL Server collation is a configuration setting that determines how the database engine should treat character data at a server, database, column level, or casting operation.
Collation name can be either a Windows collation name or a SQL collation name. All SQL Server collation names begin with SQL_.
--Get all the collations
SELECT name, description
FROM sys.fn_helpcollations()
SELECT name, description
FROM sys.fn_helpcollations()
--SQL Server Collation
SELECT SERVERPROPERTY('collation')
SELECT SERVERPROPERTY('collation')
--Database collation
SELECT name,collation_name
FROM sys.databases
WHERE NAME like '%Adventureworks%'
SQL Server Level Collation
The first is to provide a character set that defines the bit patters. SQL Server stored character data using either one byte or two-byte per character, depending on the column’s data type and assigned collation. For example, European languages require only a single-byte character set, which supports up to 256 bit patterns. On the other hand, many Asian languages include thousands of characters and require a double-byte character set, which supports up to 65,536 bit patterns.
Column Level Collation
As with database definitions, you can add the COLLATE clause when defining a character column. In this way, you can apply a specific collation to the column’s data, without impacting the rest of the database.
Sorted differently using Collation
The following example creates a simple table and inserts 4 rows. Then the example applies two collations when selecting data from the table, demonstrating how Chiapas is sorted differently.
Join differently using Collation
Sometimes you need to join tables that use different collation. In this case, you can use collation in the join.
Cheers!
Uma
Uma