T-SQL Collation Conflict
- A collation is a specification for the manner in which characters are physically stored, that is, the bit-patterns that represent each character. It also specifies the sorting and ordering rules for character strings.
- Collation can be specified at the database, table and also the column level, that is, for a field in a table. Each column in a table can have a different collation.
- If you use temporary tables as a means of temporary workspace in T-SQL procedures, you have to pay attention to collations. If the default collation of the temporary table does not match that of the database or its tables, SQL Server gives an error message indicating a collation conflict.
- Whenever you need a temporary table in T-SQL code, either create the table with the default database collation or use the "COLLATE" command when inserting into, updating and referencing the table. The default collation for the current database can be specified by the keyword "database_default" in the "COLLATE" command. As an alternative, use a separate SQL Server instance for each distinct collation.
- Execute this T-SQL query for the names of collations supported by the SQL Server instance:
select * from ::fn_helpcollations()