与临时表中的列进行比较时,SQL排序规则冲突 [英] SQL Collation conflict when comparing to a column in a temp table

查看:86
本文介绍了与临时表中的列进行比较时,SQL排序规则冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SQL查询,该查询将数据库中的值与常量进行比较:

I have a SQL query that compares a value in the database to a constant:

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.

如何解决这个问题? (无需更改数据库)

How can I get around this? (without making changes to the database)

更新:即使删除了最后一个like(字符串比较),我也会收到此错误...

UPDATE: I get this error even if I remove the last like (the string comparison)...

推荐答案

您的 id 似乎是 VARCHAR

Seems your id's are VARCHARs with different collations.

尝试以下操作:

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'

这篇关于与临时表中的列进行比较时,SQL排序规则冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆