1、5CA ierwrt啊韵说 , ., 世価面1诵曹RH鮭曲解巨!“时巳鮎刊: 難斟I* “ ) declare strlnvAge nVarchar(4000) declare strSQLln nVarchar(4000) declare strSQLOut nVarchar(4000) declare strNewRecord nVarchaT(4000)declare strSql nVarchar(200)declare sSQL nVarchar(200) declare sBegdate As nVarchar(2CX)iCou int请在数据库2008中执行文件:对象名dbo.S
2、T_CalBeglnvAge无效.sql步骤如下1在开始程序的打开SQL2008如图点连接进入选文件/打开/文件,路径 用友相关点执行就行了附: 数据库语句- 账套 005年度为 2014 升级时,软件报错对象名 dbo.ST_CalBegInvAge 无效 - 请执行以下语句use ufdata_005_2014alter table MatchVouch add bReqAnalyse bit,dIssueDate varchar(16)GO/* 对象 : StoredProcedure dbo.ST_CalBegInvAge 脚本日期 :08/15/2014 13:12:13 */SET
3、 ANSI_NULLS ONSET QUOTED_IDENTIFIER ON- 计算上年结存库龄CREATE PROCEDURE dbo.ST_CalBegInvAgecDBName Varchar(20), - 上一个账套名称CurrentDate Datetime, - 计算日期cCurDBName varchar(20) - 当前账套名称AsDeclare strLeftQty nVarchar(4000)declare cWhCode nvarchar(50)declare cInvCode nvarchar(50)declare cBatch nvarchar(50)declare
4、cFree1 nvarchar(120)declare cFree2 nvarchar(120)declare iQtty floatdeclare iNum floatdeclare autoId intdeclare iVouchQtty floatdeclare iVouchNum floatdeclare iTempQtty floatdeclare iTempNum floatdeclare strSQLInvAge nVarchar(4000)declare strInvAge nVarchar(4000)declare strSQLIn nVarchar(4000)declare
5、 strSQLOut nVarchar(4000)declare strNewRecord nVarchar(4000)declare sSQL nVarchar(200)declare sBegdate As nVarchar(200)declare iCou int- 取库存启用日期Set sBegdate = Nselect StockStartDate = cast(cValue as Datetime) from +cDBName + .accinformation + Where cSysid=ST and cName= dSTStartDateexec sp_executesql
6、 sBegdate,NStockStartDate datetime output, StockStartDateoutputIf StockStartDate is NullBeginReturnEnd- 计算本期当前结存Set strNewRecord = NInsert Into +cDBName+.STStockAgeTempTable(autoid, iqtty,inum)values(autoid, iTempQtty, iTempNum) set strLeftQty = SELECT cWhCode,cInvCode,IsNull(cBatch,) As cBatch,IsNu
7、ll(cFree1,) As cFree1,IsNull(cFree2,) As cFree2,SUM(case when bRdFlag = 1 then iQuantity else -iQuantity end) as iQtty,SUM(case when bRdFlag = 1 then iNum else - iNum end) AS iNumFrom( Select bRdFlag, cWhCode, cInvCode, iQuantity, INum, cBatch, cFree1, cFree2From + cDBName+.ST_BegInvAgeUnion ALLSele
8、ct R.bRdFlag, R.cWhCode, Rs.cInvCode, Rs.iQuantity, Rs.INum, Rs.cBatch, Rs.cFree1,Rs.cFree2 + cDBName+ .RdRecord R inner join .RdRecords Rs on R.id = Rs.idWhere R.dDate = StartDate And R.dDate = CurrentDate And cVouchType 33 And cVouchType 0) or (d.bRdFlag 1 and ds.iQuantity = StartDate and d.dDate
9、= CurrentDate and d.cWhCode = cWhCodeand ds.cInvCode = cInvCode and IsNull(ds.cBatch,) = cBatch and IsNull(ds.cFree1,) = cFree1and IsNull(ds.cFree2,) = cFree2) Xorder by dDate Desc,AutoID Desc for read only Set strSQLIn = N declare curInvIn insensitive cursor for + strSQLInset strLeftQty = Ndeclare
10、curRd cursor for + strLeftQty execute sp_executesql strLeftQty,NCurrentDate Datetime, StartDate Datetime, CurrentDate, StockStartDateopen curRdfetch next from curRd intocWhCode,cInvCode,cBatch, cFree1,cFree2,iQtty, iNum- 建立计算结果临时表Set sSQL = Nselect Num = count(1) from + cDBName +.sysobjects Wherenam
11、e = STStockAgeTempTableexec sp_executesql sSQL,NNum int output, iCou outputIf iCou 0Exec ( Drop Table + cDBName+.STStockAgeTempTable) Create Table .STStockAgeTempTable (autoId int ,iQtty float,iNum float)-sp_help ST_BegInvAgewhile fetch_status = 0beginif(iQtty 0 ) set iQtty = 0if(iNum 0 or round(iNu
12、m,6) 0) and fetch_status =0if Round(iQtty, 6) Round(iVouchQtty, 6)set iTempQtty = iVouchQttyset iQtty = Round(iQtty, 6) - Round(iVouchQtty, 6) endelse beginset iTempQtty = iQttyset iQtty = 0.0 endif Round(iNum, 6) Round(iVouchNum,6)set iTempNum = iVouchNumset iNum = Round(iNum, 6) - Round(iVouchNum,
13、 6) endset iTempNum = iNumset iNum = 0.0 end- 增加计算结果execute sp_executesql strNewRecord,autoid int, iTempQtty float, iTempNum float, autoid, iTempQtty, iTempNumfetch next from curInvIn into autoid, iVouchQtty, iVouchNum endclose curInvIndeallocate curInvInfetch next from curRd into cWhCode,cInvCode,c
14、Batch,cFree1,cFree2,iQtty, iNum endclose curRddeallocate curRd- 将结果数据输出set strSQLInvAge =NSelect ID, bRdFlag,cVouchType,cWhCode ,dDate , cCode,cRdCode,cDepCode ,cPersonCode ,cVenCode ,cHandler ,cMemo ,cMaker ,cDefine1 ,cDefine2 ,cDefine3 ,cDefine4 ,cDefine5 ,cDefine6 ,cDefine7 ,cDefine8 ,cDefine9 ,c
15、Define10 , RT.AutoID ,cInvCode,(case when x.bRdFlag = 0 then -1 * RT.iNum else RT.iNum end) As iNum,(case when x.bRdFlag = 0 then -1 * RT.iQtty else RT.iQtty end)As iQuantity ,iUnitCost ,iPrice ,cBatch,cFree1 ,cFree2 ,dVDate ,cDefine22 ,cDefine23 ,cDefine24 ,cDefine25 ,cDefine26 ,cDefine27 ,cItem_cl
16、ass , cItemCode ,cName ,cItemCNameInto + cCurDBName+.STStockAgeTempTable RT Inner Join ( Select ID, bRdFlag,cVouchType,cWhCode ,dDate , cCode,cRdCode,cDepCode ,cPersonCode ,cVenCode , cHandler ,cMemo ,cMaker ,cDefine1 ,cDefine2 , cDefine3 ,cDefine4 ,cDefine5 ,cDefine6 ,cDefine7 , cDefine8 ,cDefine9
17、,cDefine10 ,AutoID ,cInvCode, iNum ,iQuantity ,iUnitCost ,iPrice ,cBatch,cFree1 , cFree2 ,dVDate ,cDefine22 ,cDefine23 ,cDefine24 , cDefine25 ,cDefine26 ,cDefine27 ,cItem_class , cItemCode , cName ,cItemCNameUnion AllSelect R.ID, bRdFlag,cVouchType,cWhCode ,dDate , cCode,cRdCode,cDepCode ,cPersonCod
18、e ,cVenCode , cHandler ,cMemo ,cMaker ,cDefine1 ,cDefine2 , cDefine3 ,cDefine4 ,cDefine5 ,cDefine6 ,cDefine7 , cDefine8 ,cDefine9 ,cDefine10 ,AutoID ,cInvCode, iNum ,iQuantity ,iUnitCost ,iPrice ,cBatch,cFree1 , cFree2 ,dVDate ,cDefine22 ,cDefine23 ,cDefine24 , cDefine25 ,cDefine26 ,cDefine27 ,cItem
19、_class , cItemCode , cName ,cItemCName.RdRecords Rs inner join .RdRecord ROn (R.ID = Rs.ID)Where dDate = StartDate And dDate = Curre ntDate And cVouchType A nd cVouchType ”34”)X On RT.autold = X.autoldexecute sp_executesql strSQLI nv Age,Curre ntDate Datetime, StartDate DatetimeCurre ntDate,StockSta
20、rtDate然后再回到系统管理/系统/升级SQL SERVE数据阳1己件】选择005账套的20142015年度,升级提示成功蜃T卜辰诗百蓉黑粋RlftcSI lM5fAj予融 丁控制告血羽新I沽!tiiVg宣V Kftaid3!底加4 .蒯匕息刊犯尊t r fiF -.UM 1R- Adnir H-V .斗乍4.血口| It-S i(FSEE*TEIB,如果出现以下情况:列名cMem(无效请执行这个文件 : 更新数据库 MatchVouchs.sql-账套116年度为2016升级时,软件报错列名cMem(无效- 请执行以下语句USE UFDATA_116_2016alter table MatchVouchs add cMemo varchar(255) NULL
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1