Blog Pages

Cannot resolve collation conflict

In SQL SERVER, the collation can be set in column level. When compared 2 different collation column in the query, this error comes up.

WHERE ItemsTable.Collation1Col = AccountsTable.Collation2Col
“Cannot resolve collation conflict for equal to operation“.

To resolve the collation conflict add following keywords around “=” operator:
WHERE ItemsTable.Collation1Col COLLATE DATABASE_DEFAULT
 = AccountsTable.Collation2Col COLLATE DATABASE_DEFAULT

Collation can affect following areas:
  • Where clauses.
  • Join predicates.
  • Functions.
  • Databases (e.g. TempDB may be in a different collation database_default than the other databases some times).

No comments:

Post a Comment