SQL:Cannot resolve the collation conflict (字符集冲突)
SQL:Cannot resolve the collation conflict (字符集冲突)异常提示:
System.Data.SqlClient.SqlException:
Cannot resolve the collation conflict between "Chinese_PRC_CI_AS" and "Chinese_PRC_CS_AS" in the equal to operation.
通常是建立表关联时报错,如:
SELECT A.*,B.* FROM ... ON A.Code=B.Code
当A.Code字符集为Chinese_PRC_CI_AS
当B.Code字符集为Chinese_PRC_CS_AS
解决方案:
使操作符两侧的字符集相同,参考下面代码:
SELECT A.*,B.* FROM ... ON A.Code
COLLATE Chinese_PRC_CI_AS=B.Code
COLLATE Chinese_PRC_CI_AS
或者:
SELECT A.*,B.* FROM ... ON A.Code
COLLATE Chinese_PRC_CS_AS=B.Code
COLLATE Chinese_PRC_CS_AS
扫一扫加作者微信