资源描述:
《固定资产重算固定资产语句》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、用友U8各版本如果出现固定资产模块账表查询时数据有误,但是卡片管理中数据正确的情况下,在查询分析器中执行下述语句,注意下面红字部分,需要逐月修改执行。beginTRANSACTIONkk--创建临时表CREATETABLE#fq([sCardID]int,PRIMARYkeynonCLUSTERED([sCardID]))commitTRANSACTIONkk--初始化定义变量declare@Begindatetime,@enddatetime,@iperiodint,@acc_idvarchar(10),@acc_yearvarchar(10)dec
2、lare@SQLnchar(2000)--得到当前本数据库的有关信息Select@acc_id=substring(db_name(),8,3),@acc_year=substring(db_name(),12,4),@iperiod=3-----修改成需要重算总账的会计月份---SELECT@Begin=[dBegin],@end=[dEnd]FROM[UFSystem].[dbo].[UA_Period]where[cAcc_Id]=@acc_idand[iYear]=@acc_yearandiId=@iperiod--Select@acc_id,
3、@acc_year,@iperiod,@Begin,@end--取月初有效卡片序号数据,计算月初累计折旧数据if@iperiod>12returninsert#fqSELECTmax(C.[sCardID])FROM[fa_Cards]CWHERE((c.dInputDate<@Begin)AND(c.dTransDate<@BeginOrc.dTransDateIsNull)AND(c.dDisposeDate<@BeginOrc.dDisposeDateIsNull))groupbyC.[sCardNum]--Set@SQL=updatefa_to
4、talsetdblMonthDeprTotal=isnull(DT,0),dblMonthvalue=isnull(Dv,0)FROMfa_totalTleftjoin(SelectD.[sDeptNum],C.[sTypeNum],sum(D.[dblValue])DV,sum(case@iperiod-1when0then[dblDeprT1]-[dblDepr1]when1then[dblDeprT1]when2then[dblDeprT2]when3then[dblDeprT3]when4then[dblDeprT4]when5then[dbl
5、DeprT5]when6then[dblDeprT6]when7then[dblDeprT7]when8then[dblDeprT8]when9then[dblDeprT9]when10then[dblDeprT10]when11then[dblDeprT11]else0end)DTfrom[fa_Cards]CJOIN[fa_Cards_Detail]DOND.[sCardID]=C.[sCardID]JOIN[fa_DeprTransactions_Detail]PONC.[sCardNum]=P.[sCardNum]ANDD.[sDeptNum]
6、=P.[sDeptNum]join#fqon#fq.[sCardID]=C.[sCardID]WHEREC.[dDisposeDate]isnullgroupbyD.[sDeptNum],C.[sTypeNum])asAonT.[sDeptNum]=a.[sDeptNum]andT.[sTypeNum]=a.[sTypeNum]where(T.dblMonthDeprTotal<>isnull(DT,0)orT.dblMonthvalue<>isnull(Dv,0))andT.iperiod=@iperiod--取月末有效卡片序号数据,计算月末累计折旧
7、数据truncatetable#fqinsert#fqSELECTmax(C.[sCardID])FROM[fa_Cards]CWHERE((c.dInputDate<=@end)AND(c.dTransDate<=@endOrc.dTransDateIsNull)AND(c.dDisposeDate<=@endOrc.dDisposeDateIsNull))groupbyC.[sCardNum]--Set@SQL=updatefa_totalsetdblDeprTotal=isnull(DT,0),dblDepr=isnull(DP,0),dblva
8、lue=isnull(Dv,0)FROMfa_totalTleftjoin(SelectD.[