解决方案: |
请将2006年恢复至期初记账前状态,然后使用如下脚本调整后,重新记账! delete from ia_subsidiary Where cVoutype = '34' go Insert into IA_subsidiary (bRdFlag,dvoudate,dKeepDate,iMonth,cInvHead,cVouType,cWhCode,cInvCode,iAInQuantity, iInCost,iAInPrice,cAccounter,cMaker,cPzID,cfree1,cfree2,cfree3,cfree4,cfree5,cfree6,cfree7,cfree8,cfree9, cfree10) select 1,'2005-12-31','2006-1-1',0,cInvHead,'34',cWhCode,cInvCode,Sum(Isnull(iAInQuantity,0) - IsNull(IaOutQuantity,0)), Null,Sum(Isnull(iAInPrice,0) - IsNull(IaOutPrice,0)),'demo','demo',cPzID,cfree1,cfree2,cfree3,cfree4,cfree5,cfree6,cfree7,cfree8,cfree9, cfree10 from ufdata_XXX_2005..ia_subsidiary Where cVoutype <>'33' group by cInvHead,cWhCode,cInvCode,cPzID,cfree1,cfree2,cfree3,cfree4,cfree5,cfree6,cfree7,cfree8, cfree9,cfree10 having Round(Sum(Isnull(iAInQuantity,0) - IsNull(IaOutQuantity,0)),6) <> 0 or Round(Sum(Isnull(iAInPrice,0) - IsNull(IaOutPrice,0)),2) <> 0 go update IA_subsidiary Set iInCost = IaInPrice / iaInquantity Where iaInquantity <> 0 |