解决方案: |
(1)将2004年两清记录全部清空,重新结转,在2005年手工两清,一定要保证金额对应;
(2)按余额结转;
(3)在2005年后台数据库能够找到50多条差异记录在2004年中有对应的记录,可以相应修改,但剩余80多条记录是没有对应关系的。 执行如下脚本可以查询到相应记录:(执行前请做好备份,需要把脚本中对应的账套号改过来)
use ufdata_006_2005
select isnull(a.mb,0) as mb,(isnull(b.md,0)-isnull(b.mc,0)) as md,b.ccode,b.ccus_id,b.csup_id
into tmp01
from ( select (case when cbegind_c='借' then mb else -mb end) as mb,ccode,ccus_id,csup_id
from gl_accass where iperiod=1 and (ccus_id is not null or csup_id is not null) ) a
right join ( select sum(md) as md,sum(mc) as mc,ccode,ccus_id,csup_id
from gl_accvouch where iperiod=0 and (ccus_id is not null or csup_id is not null)
group by ccode,ccus_id,csup_id) b
on a.ccode=b.ccode and isnull(a.ccus_id,0)=isnull(b.ccus_id,0) and isnull(a.csup_id,0)=isnull(b.csup_id,0)
where isnull(a.mb,0)<>(isnull(b.md,0)-isnull(b.mc,0))
alter table tmp01 add auto_id int IDENTITY (1,1)
select a.auto_id,b.i_id
into tmp02
from tmp01 a
left join (select (case when isnull(md,0)<>0 then md else -mc end) as m1 ,*
from ufdata_006_2004..gl_accvouch where nfrat=0 and iflagperson is not null ) b
on a.ccode=b.ccode and isnull(a.ccus_id,0)=isnull(b.ccus_id,0) and isnull(a.csup_id,0)=isnull(b.csup_id,0) |