我有一个SQL查询,将数据库中的值与常量进行比较:
SELECT * FROM my_table INNER JOIN #TempTable tem ON my_table.id = temp.id AND my_table.key = 'SOME STRING'
我得到错误:
Cannot resolve the collation conflict between "sql_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.
我该怎么办? (不改变数据库)
解决方法
似乎你的id是不同排序的VARCHAR.
尝试这个:
SELECT * FROM my_table INNER JOIN #TempTable tem ON my_table.id = temp.id COLLATE sql_Latin1_General_CP1_CI_AS AND my_table.key = 'SOME STRING'