Sql-server – SQL Server collation mismatch

collationsql server

I have database server with collation: SQL_Latin1_General_CP1_CI_AS

I got database backup file which collation is: Latin1_General_CI_AS

When I'm restoring this database and executing some SQL, I'm getting this error:

Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation

I've changed database collation to match:

ALTER DATABASE database_name
COLLATE SQL_Latin1_General_CP1_CI_AS

And now getting even more this kind of errors.

Is there any common way to modify all database object collation to prevent this kind of issues?

Best Answer

You have change all user tables and columns individually, droppng and creating all constraints as needed. It's straightforward, just tedious. (SO link)

You can also use COLLATE DATABASE_DEFAULT to coerce collations in code without actually knowing what one is used.