解决方案: |
编写的脚本,直接执行该脚本进行2006年数据的修改,之后数据正常。 use ufdata_001_2005 Select rdrecords.autoid, RdRecord.dDate,RdRecords.dSDate,RdRecord.cCode,Vendor.cVenAbbName, Inventory.cInvCode,Inventory.cInvAddCode,Inventory.cInvName, warehouse.cWhName,Inventory.cInvStd,Inventory.cInvM_Unit, ltrim(str(RdRecords.iQuantity - RdRecords.iSQuantity,30,3)) As iNum2, ltrim(str(Isnull(RdRecords.fACost,0),30,2)) As iUnitCost, ltrim(str(RdRecords.iAPrice - (RdRecords.iSQuantity)*Isnull(RdRecords.fACost,0),30,2)) As iPrice, (case when Inventory.iInvRcost IS NULL then NULL else ltrim(str(Inventory.iInvRCost ,30,2)) end) As iInvRCost, (case when Inventory.iInvRcost IS NULL then NULL else ltrim(str(Inventory.iInvRcost * (RdRecords.iQuantity- RdRecords.iSQuantity),30,2)) end) As iInvRMoney, RdRecord.cMemo, RdRecord.cDefine1, RdRecord.cDefine2, RdRecord.cDefine3, RdRecord.cDefine4, ltrim(str(RdRecord.cDefine5,30,2)) As cDefine5, RdRecord.cDefine6, ltrim(str(RdRecord.cDefine7,30,2)) As cDefine7, RdRecord.cDefine8, RdRecord.cDefine9, RdRecord.cDefine10, RdRecords.cDefine22,RdRecords.cDefine23,RdRecords.cDefine24,RdRecords.cDefine25,Ltrim(str(RdRecords.cDefine26,30,2)) As cDefine26,lTrim(str(RdRecords.cDefine27,30,2)) As cDefine27, ltrim(str((case when RdRecords.iNum IS NULL then NULL else (RdRecords.iNum - (case when RdRecords.iSNum IS NULL then 0 else RdRecords.iSNum end)) end),30,2)) As iNum1,RdRecord.ID into ufdata_001_2006..temaa FROM WareHouse RIGHT JOIN (Vendor RIGHT JOIN (RdRecord INNER JOIN (Inventory INNER JOIN RdRecords ON Inventory.cInvCode = RdRecords.cInvCode) ON RdRecord.ID = RdRecords.ID) ON Vendor.cVenCode = RdRecord.cVenCode) ON WareHouse.cWhCode = RdRecord.cWhCode Where (abs(RdRecords.iQuantity) >abs(RdRecords.iSQuantity)) And (RdRecord.dDate Between '2004-01-01' And '2005-12-31') And RdRecord.cSource='采购' And RdRecord.cBusType='普通采购' Order By RdRecord.dDate,RdRecord.ID -- use ufdata_001_2006 select autoid,dsdate,isquantity,isnum,imoney into ufdata_001_2006..tembb from ufdata_001_2005..rdrecord rd join ufdata_001_2005..rdrecords rds on rd.id=rds.id where autoid in ( Select autoid--,rdrecords.dsdate,isquantity,isnum,imoney--RdRecords.dSDate,RdRecord.cCode,Vendor.cVenAbbName, Inventory.cInvCode,Inventory.cInvAddCode,Inventory.cInvName, warehouse.cWhName,Inventory.cInvStd,Inventory.cInvM_Unit, ltrim(str(RdRecords.iQuantity - RdRecords.iSQuantity,30,3)) As iNum2, ltrim(str(Isnull(RdRecords.fACost,0),30,2)) As iUnitCost, ltrim(str(RdRecords.iAPrice - (RdRecords.iSQuantity)*Isnull(RdRecords.fACost,0),30,2)) As iPrice, (case when Inventory.iInvRcost IS NULL then NULL else ltrim(str(Inventory.iInvRCost ,30,2)) end) As iInvRCost, (case when Inventory.iInvRcost IS NULL then NULL else ltrim(str(Inventory.iInvRcost * (RdRecords.iQuantity- RdRecords.iSQuantity),30,2)) end) As iInvRMoney, RdRecord.cMemo, RdRecord.cDefine1, RdRecord.cDefine2, RdRecord.cDefine3, RdRecord.cDefine4, ltrim(str(RdRecord.cDefine5,30,2)) As cDefine5, RdRecord.cDefine6, ltrim(str(RdRecord.cDefine7,30,2)) As cDefine7, RdRecord.cDefine8, RdRecord.cDefine9, RdRecord.cDefine10, RdRecords.cDefine22,RdRecords.cDefine23,RdRecords.cDefine24,RdRecords.cDefine25,Ltrim(str(RdRecords.cDefine26,30,2)) As cDefine26,lTrim(str(RdRecords.cDefine27,30,2)) As cDefine27, ltrim(str((case when RdRecords.iNum IS NULL then NULL else (RdRecords.iNum - (case when RdRecords.iSNum IS NULL then 0 else RdRecords.iSNum end)) end),30,2)) As iNum1,RdRecord.ID FROM WareHouse RIGHT JOIN (Vendor RIGHT JOIN (RdRecord INNER JOIN (Inventory INNER JOIN RdRecords ON Inventory.cInvCode = RdRecords.cInvCode) ON RdRecord.ID = RdRecords.ID) ON Vendor.cVenCode = RdRecord.cVenCode) ON WareHouse.cWhCode = RdRecord.cWhCode Where (abs(RdRecords.iQuantity) >abs(RdRecords.iSQuantity)) And (RdRecord.dDate Between '2004-01-01' And '2005-12-31') And RdRecord.cSource='采购' And RdRecord.cBusType='普通采购' and autoid not in ( select autoid from temaa) ) --查询 /* select rdrecords.dsdate,tembb.dsdate,rdrecords.isquantity,tembb.isquantity, rdrecords.isnum,tembb.isnum,rdrecords.imoney,tembb.imoney from rdrecords join tembb on rdrecords.autoid=tembb.autoid */ --update --begin tran update rdrecords set rdrecords.dsdate=tembb.dsdate, rdrecords.isquantity=tembb.isquantity, rdrecords.isnum=tembb.isnum, rdrecords.imoney=tembb.imoney from rdrecords join tembb on rdrecords.autoid=tembb.autoid --commit tran /* use ufdata_001_2006 drop table temaa drop table tembb */ |