Sql – Cannot resolve the collation conflict between “Latin1_General_BIN” and “Latin1_General_CI_AS” in the equal to operation

sqlsql servertsql

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

Best Answer

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