if exists(select 1 from sysobjects where name='t1' and xtype='u') drop table t1
--生成临时表
Select '2013-08' as cDaYf,A.cKhBm,A.cNpBm,cQyBm,cYwyBm,iSySl as iYcSl into t1 From EC_Ddb A,EC_KhXx B
Where A.cKhBm=B.cKhBm AND iDnZt=1 AND B.iKhZt=1 AND B.cYwyBm='005'
if exists(select 1 from sysobjects where name='t2' and xtype='u') drop table t2
--生成临时表
select cDaYf,cKhBm,cNpBm,cQyBm,cYwyBm,iYcSl into t2 from
--比对不同
select * from t1 where not exists (select 1 from t2 where t1.cDaYf=t2.cDaYf and t1.cKhBm=t2.cKhBm and t1.cNpBm=t2.cNpBm and t1.cQyBm=t2.cQyBm and t1.cYwyBm=t2.cYwyBm)