Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am getting the following error 

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

Code

SELECT @PARTS = SUM(Llines_1.[qty]) from pick 
RIGHT OUTER JOIN op AS Llines_1 ON pick.picknote = 
Llines_1.[order_no] WHERE (pick.batchid = @batchid) AND (product = @product)
group by product Order By product

I have tired using COLLATE SQL_Latin1_General_CP1_CI_AS before the from but still get the same error.

SELECT @PARTS = SUM(Llines_1.[qty])  COLLATE SQL_Latin1_General_CP1_CI_AS
from pick RIGHT OUTER JOIN op AS Llines_1 ON pick.picknote = Llines_1.
[order_no] WHERE (pick.batchid = @batchid) 
AND (product = @product) group by product Order By product
like image 326
Emma Avatar asked Jun 22 '17 09:06

Emma


People also ask

What is Latin1_General_BIN collation?

Common collation names either end in _BIN or _CI_AS such as Latin1_General_BIN or SQL_Latin1_General_CI_AS. The _BIN means that this is a binary sort order where strings will be sorted using a computer binary order, the result is that A-Z are before a-z and things like accented characters will be at the end.

Is SQL_Latin1_General_CP1_CI_AS the same as Latin1_General_CI_AS?

The SQL_Latin1_General_CP1_CI_AS collation is a SQL collation and the rules around sorting data for unicode and non-unicode data are different. The Latin1_General_CI_AS collation is a Windows collation and the rules around sorting unicode and non-unicode data are the same.

What is a collation conflict in SQL?

In Microsoft SQL Server, the collation can be set at the column level. When you compare (or concatenate) two columns having different collation in a query, this error occurs: Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "French_CI_AS" in the equal to operation. —

What is collate Database_default?

MSDN states COLLATE DATABASE_DEFAULT clause casts the collation of an expression, column definition, or database definition to inherit the collation of the "current database". To complement MSDN, the "current database" is the context of the database where the query is executed.


1 Answers

I assume that collations of picknote and order_no are different Try this:

SELECT @PARTS = SUM(Llines_1.[qty])  
from pick 
RIGHT OUTER JOIN op AS Llines_1 ON pick.picknote = Llines_1.[order_no] COLLATE SQL_Latin1_General_CP1_CI_AS
WHERE (pick.batchid = @batchid) 
    AND (product = @product) group by product Order By product
like image 174
Mikhail Lobanov Avatar answered Sep 21 '22 14:09

Mikhail Lobanov