解决方案: |
解决办法及步骤: 一、删除1月份固定资产凭证及1月份新增的资产卡片; 二、生成临时数据表: select scardnum,max(scardid) as scardid into tempdb..scid from fa_cards group by scardnum select b.sDeptNum,b.sTypeNum,sum(dblMonthValue) as ycyz,sum(dblPeriodValue) as qcyz, sum(dblMonthDeprTotal) as yclj,sum(dblPeriodDeprTotal) as qclj, SUM(dblDepr1) AS byzj into tempdb..qcsj from fa_DeprTransactions a inner join (select scardnum,sDeptNum,sTypeNum from fa_cards where scardid in (select scardid from tempdb..scid) ) b on a.scardnum=b.scardnum group by b.sDeptNum,b.sTypeNum 三、在SQL SERVER企业管理器该帐套2006年度库FA_TOTAL表中增加一个字段“ID”,属性为标识字段,种子为1,自增量为1; 四、在SQL查询分析器该帐套2006年度参照执行如下脚本,删除多余固定资产总帐表中多余的记录: delete from fa_total where id in ( select c.id from fa_total c left join tempdb..qcsj d on c.sdeptnum=d.sdeptnum and c.stypenum=d.stypenum where iperiod=1 and d.sdeptnum is null ) 五、在SQL SERVER企业管理器该帐套2006年度库FA_TOTAL表中,删除FA_TOTAL表中第三步中增加的字段“ID”; 六、在SQL查询分析器该帐套2006年度参照执行如下脚本,补充fa_total表中缺少的记录: --fa_total表中缺的记录: select * from fa_total c right join tempdb..qcsj d on c.sdeptnum=d.sdeptnum and c.stypenum=d.stypenum where c.sdeptnum is null --补充fa_total表中缺的记录: INSERT INTO [fa_Total]([sDeptNum], [sTypeNum], [iPeriod], [lMonthCount], [lCount], [dblYearValue], [dblYearDeprTotal], [dblLastAccrualValue], [dblLastDepr], [dblLastAddValue], [dblLastDecValue], [dblLastWork], [dblLastWorkTotal], [dblWork], [dblWorkT], [dblMonthValue], [dblValue], [dblMonthDeprTotal], [dblDeprTotal], [dblAddValue], [dblDecValue], [dblTransInDeprTotal], [dblTransOutDeprTotal], [dblAccrualValue], [dblDepr]) VALUES('04','02',1,1,1,18668.0,12611.05,0,0,0,0,0,0,0,0,18668.0, 18668.0, 12611.05, 12611.05,0,0,0,0,0,0) 七、在SQL查询分析器该帐套2006年度参照执行如下脚本,修复FA_TOTAL表中年初原值、年初累计折旧、月初原值 、月初累计折旧 、月末原值 、月末累计折旧、本月计提折旧等字段的数据: update c set dblYearValue=d.qcyz,dblMonthValue=d.ycyz, dblYearDeprTotal=d.qclj,dblMonthDeprTotal=d.yclj, dblValue=d.qcyz,dblDeprTotal=qclj+byzj, dblDepr=d.byzj from fa_total c inner join tempdb..qcsj d on c.sdeptnum=d.sdeptnum and c.stypenum=d.stypenum where iperiod=1 八、补录1月份的新增卡片,进行后续业务处理即可。 注意做好数据备份!! |