Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am getting below said collation error since I have moved from a desktop machine to a laptop. My database has hundreds of stored procedures, so any solution like overriding some queries or fix collation for a column is not possible for me.

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

My problem is not unique and I have searched for this quite a lot, but solutions available suggest me to override queries with some code which is not feasible. Please suggest some solution that may avoid this collation thing.

I have tried this to alter my database collation.

ALTER DATABASE testDB   COLLATE French_CI_AI ;   GO   

Thanks.

like image 249
TechnicalSmile Avatar asked Feb 22 '12 10:02

TechnicalSmile


People also ask

How do you solve Cannot resolve the collation conflict between SQL_Latin1_General_CP1_CI_AS and Latin1_General_CI_AS in the equal to operation?

Issue: Cannot resolve the collation conflict between “SQL_Latin1_General_CP1_CI_AS” and “Latin1_General_CI_AS” Simply apply the default collation to the fields you are comparing.

Can not resolve the collation conflict?

error (Cannot resolve the collation conflict between .... ) usually occurs while comparing data from multiple databases. since you cannot change the collation of databases now, use COLLATE DATABASE_DEFAULT.

What does collate SQL_Latin1_General_CP1_CI_AS mean?

The collate clause is used for case sensitive and case insensitive searches in the columns of the SQL server. There are two types of collate clause present: SQL_Latin1_General_CP1_CS_AS for case sensitive. SQL_Latin1_General_CP1_CI_AS for case insensitive.

How do I change SQL Server collation settings?

You can change the collation of any new objects that are created in a user database by using the COLLATE clause of the ALTER DATABASE statement. This statement does not change the collation of the columns in any existing user-defined tables. These can be changed by using the COLLATE clause of ALTER TABLE.


2 Answers

Just use the following syntax to collate on the fly when joining tables with different collations. I integrate systems, so I have to do this a lot.

select * from [Product] p join [category] c  on   c.[Name] collate SQL_Latin1_General_CP1_CI_AS  =  p.[Name] collate SQL_Latin1_General_CP1_CI_AS 
like image 147
Master Styles Avatar answered Sep 20 '22 03:09

Master Styles


USE master; GO ALTER DATABASE PRATAP COLLATE Latin1_General_CI_AS_KS_WS ; GO  --Verify the collation setting. SELECT name, collation_name FROM sys.databases WHERE name = N' PRATAP '; GO 
like image 29
PRATAP Avatar answered Sep 17 '22 03:09

PRATAP