存储过程.sql 5.3 KB

12345678910111213141516171819202122232425262728293031
  1. --将其他入库单传递到中间库
  2. if exists (select * from sysobjects where id = object_id('dbo.usp_transrdrecord09') )
  3. drop procedure dbo.usp_transrdrecord09
  4. go
  5. Create PROCEDURE usp_transrdrecord09
  6. @v_start datetime, --开始时间
  7. @v_end datetime --结束时间
  8. as
  9. --cDefine5=1 代表是从旺店通传递回来的数据,不需要回传
  10. select Id into #t_1 from RdRecord08 where dnmaketime>=@v_start and dnmaketime <= @v_end and ISNULL(cDefine5,0) = 0
  11. if @@ROWCOUNT = 0 return
  12. --删除中间库已存在的资料
  13. delete from wtu..rdrecord08 where id in (select id from #t_1)
  14. delete from wtu..rdrecords08 where id in (select id from #t_1)
  15. insert into wtu..rdrecord08(ID, bRdFlag, cVouchType, cBusType, cSource, cBusCode, cWhCode, dDate, cCode, cRdCode, cDepCode, cPersonCode, cPTCode, cSTCode, cCusCode, cVenCode, cOrderCode, cARVCode, cBillCode, cDLCode, cProBatch, cHandler, cMemo, bTransFlag, cAccounter, cMaker, cDefine1, cDefine2, cDefine3, cDefine4, cDefine5, cDefine6, cDefine7, cDefine8, cDefine9, cDefine10, dKeepDate, dVeriDate, bpufirst, biafirst, iMQuantity, dARVDate, cChkCode, dChkDate, cChkPerson, VT_ID, bIsSTQc, cDefine11, cDefine12, cDefine13, cDefine14, cDefine15, cDefine16, gspcheck, iExchRate, cExch_Name, bOMFirst, bFromPreYear, bIsLsQuery, bIsComplement, iDiscountTaxType, ireturncount, iverifystate, iswfcontrolled, cModifyPerson, dModifyDate, dnmaketime, dnmodifytime, dnverifytime, bredvouch, iFlowId, cPZID, cSourceLs, cSourceCodeLs, iPrintCount, ctransflag, csysbarcode, cCurrentAuditor)
  16. select r.ID, bRdFlag, cVouchType, cBusType, cSource, cBusCode, cWhCode, dDate, cCode, cRdCode, cDepCode, cPersonCode, cPTCode, cSTCode, cCusCode, cVenCode, cOrderCode, cARVCode, cBillCode, cDLCode, cProBatch, cHandler, cMemo, bTransFlag, cAccounter, cMaker, cDefine1, cDefine2, cDefine3, cDefine4, cDefine5, cDefine6, cDefine7, cDefine8, cDefine9, cDefine10, dKeepDate, dVeriDate, bpufirst, biafirst, iMQuantity, dARVDate, cChkCode, dChkDate, cChkPerson, VT_ID, bIsSTQc, cDefine11, cDefine12, cDefine13, cDefine14, cDefine15, cDefine16, gspcheck, iExchRate, cExch_Name, bOMFirst, bFromPreYear, bIsLsQuery, bIsComplement, iDiscountTaxType, ireturncount, iverifystate, iswfcontrolled, cModifyPerson, dModifyDate, dnmaketime, dnmodifytime, dnverifytime, bredvouch, iFlowId, cPZID, cSourceLs, cSourceCodeLs, iPrintCount, ctransflag, csysbarcode, cCurrentAuditor
  17. from RdRecord08 r,#t_1 t where t.ID=r.ID
  18. insert into wtu..rdrecords08 (AutoID, ID, cInvCode, iNum, iQuantity, iUnitCost, iPrice, iAPrice, iPUnitCost, iPPrice, cBatch, cVouchCode, cInVouchCode, cinvouchtype, iSOutQuantity, iSOutNum, cFree1, cFree2, iFlag, iFNum, iFQuantity, dVDate, iTrIds, cPosition, cDefine22, cDefine23, cDefine24, cDefine25, cDefine26, cDefine27, cItem_class, cItemCode, cName, cItemCName, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, cBarCode, iNQuantity, iNNum, cAssUnit, dMadeDate, iMassDate, cDefine28, cDefine29, cDefine30, cDefine31, cDefine32, cDefine33, cDefine34, cDefine35, cDefine36, cDefine37, iCheckIds, cBVencode, chVencode, bGsp, cGspState, cCheckCode, iCheckIdBaks, cRejectCode, iRejectIds, cCheckPersonCode, dCheckDate, cMassUnit, bChecked, bLPUseFree, iRSRowNO, iOriTrackID, coritracktype, cbaccounter, dbKeepDate, bCosting, bVMIUsed, iVMISettleQuantity, iVMISettleNum, cvmivencode, iInvSNCount, cwhpersoncode, cwhpersonname, cserviceoid, cbserviceoid, iinvexchrate, corufts, strContractGUID, iExpiratDateCalcu, cExpirationdate, dExpirationdate, cciqbookcode, iBondedSumQty, iorderdid, iordertype, iordercode, iorderseq, isodid, isotype, csocode, isoseq, cBatchProperty1, cBatchProperty2, cBatchProperty3, cBatchProperty4, cBatchProperty5, cBatchProperty6, cBatchProperty7, cBatchProperty8, cBatchProperty9, cBatchProperty10, cbMemo, irowno, strowguid, ipreuseqty, ipreuseinum, cbsourcecodels, iGroupNO, iDebitIDs, idebitchildids, OutCopiedQuantity, cbsysbarcode, iCrmVouchids, cCrmVouchCode, iposflag)
  19. select AutoID, r.ID, cInvCode, iNum, iQuantity, iUnitCost, iPrice, iAPrice, iPUnitCost, iPPrice, cBatch, cVouchCode, cInVouchCode, cinvouchtype, iSOutQuantity, iSOutNum, cFree1, cFree2, iFlag, iFNum, iFQuantity, dVDate, iTrIds, cPosition, cDefine22, cDefine23, cDefine24, cDefine25, cDefine26, cDefine27, cItem_class, cItemCode, cName, cItemCName, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, cBarCode, iNQuantity, iNNum, cAssUnit, dMadeDate, iMassDate, cDefine28, cDefine29, cDefine30, cDefine31, cDefine32, cDefine33, cDefine34, cDefine35, cDefine36, cDefine37, iCheckIds, cBVencode, chVencode, bGsp, cGspState, cCheckCode, iCheckIdBaks, cRejectCode, iRejectIds, cCheckPersonCode, dCheckDate, cMassUnit, bChecked, bLPUseFree, iRSRowNO, iOriTrackID, coritracktype, cbaccounter, dbKeepDate, bCosting, bVMIUsed, iVMISettleQuantity, iVMISettleNum, cvmivencode, iInvSNCount, cwhpersoncode, cwhpersonname, cserviceoid, cbserviceoid, iinvexchrate, corufts, strContractGUID, iExpiratDateCalcu, cExpirationdate, dExpirationdate, cciqbookcode, iBondedSumQty, iorderdid, iordertype, iordercode, iorderseq, isodid, isotype, csocode, isoseq, cBatchProperty1, cBatchProperty2, cBatchProperty3, cBatchProperty4, cBatchProperty5, cBatchProperty6, cBatchProperty7, cBatchProperty8, cBatchProperty9, cBatchProperty10, cbMemo, irowno, strowguid, ipreuseqty, ipreuseinum, cbsourcecodels, iGroupNO, iDebitIDs, idebitchildids, OutCopiedQuantity, cbsysbarcode, iCrmVouchids, cCrmVouchCode, iposflag
  20. from RdRecords08 r,#t_1 t where t.ID=r.ID