解决方案: |
解决办法如下:
1首先恢复至1月份未结帐未记帐的状态;
2在sqlserver的查询分析器对应的数据库中执行如下sql语句即可:
declare @ccode as varchar10
declare @times int set @ccode=‘122‘
set @times=1
select * into a from GL_ACCASS where i_id in select mini_id from GL_ACCASS where ccode=@ccode and iperiod=‘1‘ group by cdept_id
select cdept_id,cbegind_c, case cbegind_c when ‘贷‘ then -1*summb else summb end as tol into b from GL_ACCASS where ccode=@ccode and iperiod=‘1‘ group by cdept_id,cbegind_c order by cdept_id select cdept_id, sumtol as allTol, fangxiang=case when sumtol>0 then ‘借‘ when sumtol<0 then ‘贷‘ when sumtol=0 then ‘平‘ end, fangxiangeng=case when sumtol>0 then ‘Dr‘ when sumtol<0 then ‘Cr‘ when sumtol=0 then ‘-‘ end into c from b group by cdept_id
update a set cbegind_c=fangxiang, cbegind_c_engl=fangxiangeng, mb=case when alltol<0 then -1*alltol else alltol end, me=alltol, cendd_c=fangxiang, cendd_c_engl=fangxiangeng from c where c.cdept_id=a.cdept_ID delete from gl_accass where ccode=‘122‘
while @times<13 begin
insert into gl_accass[ccode], [cexch_name], [cdept_id], [cperson_id], [ccus_id], [csup_id], [citem_class], [citem_id], [iperiod], [cbegind_c], [cbegind_c_engl], [mb], [md], [mc], [cendd_c], [cendd_c_engl], [me], [mb_f], [md_f], [mc_f], [me_f], [nb_s], [nd_s], [nc_s], [ne_s] select [ccode], [cexch_name], [cdept_id], [cperson_id], [ccus_id], [csup_id], [citem_class], [citem_id], @times, [cbegind_c], [cbegind_c_engl], [mb], [md], [mc], [cendd_c], [cendd_c_engl], [me], [mb_f], [md_f], [mc_f], [me_f], [nb_s], [nd_s], [nc_s], [ne_s] from a set @times=@times+1
end
drop table a
go
drop table b
go
drop table c
go |