Cannot resolve collation conflict for equal to operation
SQL语句在进行联接时,发生Cannot resolve collation conflict for equal to operation.错误
----原因
中文版本MSSQL有默认的数据库排序规则,如果数据库直接还原到英文版本MSSQL上,则有些SQL联接会出现此问题。
如:
select a.ID,a.Name,a.Age,b.ClassRoomName
from Student a,ClassRoom b
where a.Name = b.studentName
此语句在CN版本里面的没有问题,但在EN版本里面出现collation conflict的问题
----解决方案
1、把Student表的Name字段排序规则修改为Chinese_PRC_CI_AS、把ClassRoom表的studentName字段排序规则修改为Chinese_PRC_CI_AS。
2、修改语句
select a.ID,a.Name,a.Age,b.ClassRoomName
from Student a,ClassRoom b
where a.Name = b.studentName COLLATE database_default
----个人建议
英文版本MSSQL下建立数据库,且所有SQL语句的相关操作均在英文版本下完成。