《解决用友U8固定资产对账不平》由会员分享,可在线阅读,更多相关《解决用友U8固定资产对账不平(4页珍藏版)》请在金锄头文库上搜索。
1、begin TRANSACTION kk-创建临时表CREATE TABLE #fq(sCardID int ,PRIMARY key nonCLUSTERED (sCardID) commit TRANSACTION kk-初始化定义变量declare Begin datetime,end datetime,iperiod int, acc_id varchar(10), acc_year varchar(10)declare SQL nchar(2000)-得到当前本数据库的有关信息select acc_id=999, acc_year=2013, iperiod=1,Begin=2013
2、-01-01 00:00:00.000, end=2013-01-31 00:00:00.000-修改成需要重算总账的相关信息-SELECT Begin=dBegin, end =dEndFROM UFSystem.dbo.UA_Period - where cAcc_Id=acc_id and iYear =acc_year and iId=iperiod-Select acc_id,acc_year,iperiod,Begin,end-取月初有效卡片序号数据,计算月初累计折旧数据if iperiod12 returninsert #fq SELECT max(C.sCardID)FROM
3、fa_Cards CWHERE (c.dInputDate isnull(DT,0) or T.dblMonthvalue isnull(DT,0) or t.dblDeprisnull(Dv,0) and T.iperiod=iperiodtruncate table #fq-取本月新增或变动有效卡片序号数据,计算本月折旧变动情况insert #fq SELECT C.sCardIDFROM fa_Cards C WHERE (c.dInputDate between begin and end) or (c.dTransDate between begin and end)or (c.dD
4、isposeDate between begin and end) update fa_totalset dblTransInDeprTotal=indt,dblTransOutDeprTotal=(outdt)FROM fa_total T left join (Select D.sDeptNum,C.sTypeNum,sum(d.dblTransInDeprTCard) inDt,sum(d.dblTransOutDeprTCard+ case when c.iopttypeisnull(outdt,0) or dblTransInDeprTotalisnull(indt,0)drop table #fq