I am using below query in which I need to specify collation hint to avoid collation issues across databases as this query uses tables from 2 databases.
Msg 468, Level 16, State 9, Line 12 Cannot resolve the collation conflict between "Latin1_General_CS_AI" and "Latin1_General_CS_AS" in the equal to operation.
Currently I am getting above error for collation conflicts when I run some of the queries which uses different databases with different collations:
Delete from table1 where oldcolumn in
(
select newcolumn from Database2.dbo.table2
where invoiceid = @invno
and complete = 0
)
I changed the query to include collation hint as below:
Delete from table1 where oldcolumn COLLATE SQL_Latin1_General_CP1_CS_AS in
(
select newcolumn from Database2.dbo.table2
where invoiceid = @invno
and complete = 0
)
invoiceid = @invno
ever generate runtime collation conflit error? Note: I am asking this question as I do not have access to any of the above 2 databases and the script will be run on actual databases.
Use Below Query :
DELETE FROM Table1
WHERE Table1.ID IN (
SELECT Table1.ID
FROM Table1
INNER JOIN Database2.dbo.Table2 Table2 ON Table2.NewColumn = Table1.OldColumn COLLATE SQL_Latin1_General_CP1_CS_AS
WHERE Table2.invoiceid = @invno
AND Table2.complete = 0
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.