Database Collation

Photo by Sigmund on Unsplash

Database Collation

Which is a good collation for Turkish?

Quick Answer: Turkish_CI_AS

CI : Case insensitive comparisons so 'ABC' would equal 'abc'

AS : Accent sensitive, so 'ü' does not equal 'u'

To view Collation of DB:

SELECT SERVERPROPERTY('collation') AS ServerCollation;

If you create a column without a specific collation, it will be listed as NULL in in sys.columns, meaning the collation of the column will be the same as the database default.

SELECT t.name TableName, c.name ColumnName, collation_name
FROM sys.columns c
inner join sys.tables t on c.object_id = t.object_id;

What is SQL_Latin1_General_CP1_CI_AS stand for?

Breaks up into interesting parts:

  • latin1 makes the server treat strings using charset latin 1, basically ascii

  • CP1 stands for Code Page 1252

  • CI case insensitive comparisons so 'ABC' would equal 'abc'

  • AS accent sensitive, so 'ü' does not equal 'u'

https://www.sqlshack.com/sql-server-collation-introduction-with-collate-sql-casting/