日期:2014-05-18  浏览次数:20439 次

varchar VS char 查询
select   a.prt_spec   from   server.testzmpdm.dbo.product   a,   mf_bom   b   where   b.spc   is   null     and     a.prt_productcode=(cast(b.prd_no     as   char(500)))

报错:
Server:   Msg   446,   Level   16,   State   9,   Line   1
Cannot   resolve   collation   conflict   for   equal   to   operation.

条件只为b.spc   is   null执行正常.

a.prt_productcode   char(30)  
b.prd_no   varchar   (30)


------解决方案--------------------
try:
select a.prt_spec from server.testzmpdm.dbo.product a, mf_bom b where b.spc is null and a.prt_productcode=rtrim((cast(b.prd_no as char(500)))) Collate Chinese_PRC_CS_AS_KS_WS
------解决方案--------------------
select databasepropertyex( '這裏寫數據庫名 ', 'collation ')