解决方案: |
请参照如下步骤,从用户备份帐套中还原已丢失的材料出库单记录: --需要补充的rdrecord主表记录: create view rd as select distinct a.* from rdrecord a inner join rdrecords b on a.id=b.id where b.autoid in (select irdsid from UFDATA_222_2006..OM_MatSettleVouch as a left join UFDATA_222_2006..OM_MatSettleVouchs as b on a.msid=b.msid full join UFDATA_222_2006..rdrecords as c on c.autoid=irdsid where cvouchtype='11' and c.autoid is null ) go --需要补充的rdrecords子表记录: create view rds as select distinct b.* from rdrecord a inner join rdrecords b on a.id=b.id where b.autoid in (select irdsid from UFDATA_222_2006..OM_MatSettleVouch as a left join UFDATA_222_2006..OM_MatSettleVouchs as b on a.msid=b.msid full join UFDATA_222_2006..rdrecords as c on c.autoid=irdsid where cvouchtype='11' and c.autoid is null ) go --补充主表: INSERT INTO [UFDATA_222_2006].[dbo].[RdRecord]([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], [iNetLock], [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], [cPsPcode], [cMPoCode], [gspcheck], [ipurorderid], [ipurarriveid], [iproorderid], [iarriveid], [isalebillid], [iTaxRate], [iExchRate], [cExch_Name], [cShipAddress], [bOMFirst], [iDiscountTaxType]) select ID, bRdFlag, cVouchType, cBusType, cSource, cBusCode, cWhCode, dDate, cCode, cRdCode, cDepCode, cPersonCode, cPTCode, cSTCode, cCusCode, cVenCode, cOrderCode, cARVCode, cBillCode, cDLCode, cProBatch, cHandler, 'shujutiaozheng', bTransFlag, cAccounter, cMaker, iNetLock, 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, cPsPcode, cMPoCode, gspcheck, ipurorderid, ipurarriveid, iproorderid, iarriveid, isalebillid, iTaxRate, iExchRate, cExch_Name, cShipAddress, bOMFirst, iDiscountTaxType from rd --补充子表: INSERT INTO [UFDATA_222_2006].[dbo].[RdRecords]([AutoID], [ID], [cInvCode], [iNum], [iQuantity], [iUnitCost], [iPrice], [iAPrice], [iPUnitCost], [iPPrice], [cBatch], [cObjCode], [cVouchCode], [cFree1], [cFree2], [iFlag], [dSDate], [iTax], [iSQuantity], [iSNum], [iMoney], [iSOutQuantity], [iSOutNum], [iFNum], [iFQuantity], [dVDate], [iTrIds], [cPosition], [cDefine22], [cDefine23], [cDefine24], [cDefine25], [cDefine26], [cDefine27], [cItem_class], [cItemCode], [iPOsID], [fACost], [iDLsID], [iSBsID], [iSendQuantity], [iSendNum], [cName], [cItemCName], [iEnsID], [cFree3], [cFree4], [cFree5], [cFree6], [cFree7], [cFree8], [cFree9], [cFree10], [cBarCode], [iNQuantity], [iNNum], [cAssUnit], [dMadeDate], [iMassDate], [cDefine28], [cDefine29], [cDefine30], [cDefine31], [cDefine32], [cDefine33], [cDefine34], [cDefine35], [cDefine36], [cDefine37], [iMPoIds], [iCheckIds], [cBVencode], [cInVouchCode], [bGsp], [cGspState], [iArrsId], [cCheckCode], [iCheckIdBaks], [cRejectCode], [iRejectIds], [cCheckPersonCode], [dCheckDate], [iOriTaxCost], [iOriCost], [iOriMoney], [iOriTaxPrice], [ioriSum], [iTaxRate], [iTaxPrice], [iSum], [bTaxCost], [cPOID], [cMassUnit], [cMoLotCode], [iRefundInspectFlag], [iMaterialFee], [iProcessCost], [iProcessFee], [dMSDate], [iSMaterialFee], [iSProcessFee], [iOMoDID], [iSoDID], [strContractId], [strCode], [bFilled], [bChecked], [bRelated], [iOMoMID], [cmworkcentercode], [iMatSettleState], [iBillSettleCount], [iSoType], [iEqDID], [cVendorCode]) select AutoID, ID, cInvCode, iNum, iQuantity, iUnitCost, iPrice, iAPrice, iPUnitCost, iPPrice, cBatch, cObjCode, cVouchCode, cFree1, cFree2, iFlag, dSDate, iTax, iSQuantity, iSNum, iMoney, iSOutQuantity, iSOutNum, iFNum, iFQuantity, dVDate, iTrIds, cPosition, cDefine22, cDefine23, cDefine24, cDefine25, cDefine26, cDefine27, cItem_class, cItemCode, iPOsID, fACost, iDLsID, iSBsID, iSendQuantity, iSendNum, cName, cItemCName, iEnsID, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, cBarCode, iNQuantity, iNNum, cAssUnit, dMadeDate, iMassDate, cDefine28, cDefine29, cDefine30, cDefine31, cDefine32, cDefine33, cDefine34, cDefine35, cDefine36, cDefine37, iMPoIds, iCheckIds, cBVencode, cInVouchCode, bGsp, cGspState, iArrsId, cCheckCode, iCheckIdBaks, cRejectCode, iRejectIds, cCheckPersonCode, dCheckDate, iOriTaxCost, iOriCost, iOriMoney, iOriTaxPrice, ioriSum, iTaxRate, iTaxPrice, iSum, bTaxCost, cPOID, cMassUnit, cMoLotCode, iRefundInspectFlag, iMaterialFee, iProcessCost, iProcessFee, dMSDate, iSMaterialFee, iSProcessFee, iOMoDID, iSoDID, strContractId, strCode, bFilled, bChecked, bRelated, iOMoMID, cmworkcentercode, iMatSettleState, iBillSettleCount, iSoType, iEqDID, cVendorCode from rds 缺0000215614材料出库单的记录 通过如下脚本即可得知0000215614采购入库单及其到冲的材料出库单都没有记帐: select * from ia_subsidiary where id in (select irdsid from OM_MatSettleVouch as a left join OM_MatSettleVouchs as b on a.msid=b.msid where a.ccode between '20061005056' and '20061005061' ) --处理0000215614单据的方法: --1、删除该采购入库单对应的核销单: delete from OM_MatSettleVouchs where msid in (select b.msid from OM_MatSettleVouch as a left join OM_MatSettleVouchs as b on a.msid=b.msid where a.ccode between '20061005056' and '20061005061' ) delete from OM_MatSettleVouch where ccode between '20061005056' and '20061005061' --2、通过如下语句删除该采购入库单的结算标志,然后在软件中删除该采购入库单: update b set imatsettlestate=0 from rdrecord a inner join rdrecords b on a.id=b.id where a.ccode='单据号' and cvouchtype='01' --3、参照执行如下语句,还原委外订单、材料耗用表中材料出库数量为0: -查询委外订单主 update om_modetails set iMaterialSendQty=0 where moid=(select moid from OM_MOMain where ccode='委外订单号') update om_momaterials set isendqty=0 where moid=(select moid from OM_MOMain where ccode='委外'订单号') --4、重新录入或参照生成该采购入库单并进行核销即可; --删除临时视图 drop view rd,rds 【注意事项】 注意将客户数据做好备份!导入数据后核对一下数据,检查报表及业务操作是否正常,有问题早点发现早点解决。 |