Thursday, February 21, 2013

SQL Server Collation Conflicts

If you have two fields with different collation types a SQL statement can throw the following error:

Cannot resolve collation conflict for equal to operation

A simple fix for this is to add the following keyword around the = operator as described here:


SELECT ID
FROM ItemsTable
INNER JOIN AccountsTable
WHERE ItemsTable.Collation1Col COLLATE DATABASE_DEFAULT
= AccountsTable.Collation2Col COLLATE DATABASE_DEFAULT

No comments: