Sql server中Collation conflict问题

来源:互联网 发布:淘宝网购手机 编辑:程序博客网 时间:2024/05/16 10:09
SQL语句查询时
select A.Code,A.Name,a.Systemcode,B.ID,B.LogType,B.DMCode,B.IP,B.Department,B.CreateBy,B.CreateTime
from DM_Document_TD as A left join DM_LOG_TD as B
on A .Code=B .DMCode 


结果在运行时碰到这样一个问题,问题描述:
Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Chinese_PRC_CI_AS" in the equal to operation.
到网上搜了一下,了解了问题产生的原因,原来是两个数据库的collation不一致导致的,将查询语句改成如下:


select A.Code,A.Name,a.Systemcode,B.ID,B.LogType,B.DMCode,B.IP,B.Department,B.CreateBy,B.CreateTime
from DM_Document_TD as A left join DM_LOG_TD as B
on A .Code collate chinese_prc_ci_as =B .DMCode