資源描述:
《固定資產重算固定資產語句》由會員上傳分享,免費在線閱讀,更多相關內容在應用文檔-天天文庫。
1、用友U8各版本如果出現(xiàn)固定資產模塊賬表查詢時數(shù)據(jù)有誤,但是卡片管理中數(shù)據(jù)正確的情況下,在查詢分析器中執(zhí)行下述語句,注意下面紅字部分,需要逐月修改執(zhí)行。beginTRANSACTIONkk--創(chuàng)建臨時表CREATETABLE#fq([sCardID]int,PRIMARYkeynonCLUSTERED([sCardID]))commitTRANSACTIONkk--初始化定義變量declare@Begindatetime,@enddatetime,@iperiodint,@acc_idvarchar(10),@acc_yearvarchar(10)dec
2、lare@SQLnchar(2000)--得到當前本數(shù)據(jù)庫的有關信息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--取月初有效卡片序號數(shù)據(jù),計算月初累計折舊數(shù)據(jù)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--取月末有效卡片序號數(shù)據(jù),計算月末累計折舊
7、數(shù)據(jù)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.[