tempdb的排序规则为Latin1_General_100_CI_AI
。数据库的排序规则也是Latin1_General_100_CI_AI
。然而,以下SQL语句:
SELECT *
FROM ##CitiesMapping AS cm
INNER JOIN Cities ON cm.CityName=Cities.Name
返回:
Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_100_CI_AI" in the equal to operation.
服务器默认排序规则也是Latin1_General_100_CI_AI
答案 0 :(得分:2)
检查所涉及的表格:
SELECT name, collation_name, OBJECT_NAME(object_id)
FROM sys.columns
WHERE OBJECT_NAME(object_id) IN ('Cities')
答案 1 :(得分:2)
对于单个列,可能会对排序规则设置不同。斯图尔特的询问会告诉你。如果它们是不同的排序规则,您可以指定比较任一侧使用的排序规则,如下所示:
SELECT *
FROM ##CitiesMapping AS cm
INNER JOIN Cities
ON cm.CityName COLLATE DATABASE_DEFAULT = Cities.Name COLLATE DATABASE_DEFAULT;
我希望这可以帮助你。