|
楼主 |
发表于 2013-1-22 15:09:28
|
显示全部楼层
INSERT INTO Dispatchlists(DLID,iCorID,cWhCode,cInvCode,iQuantity,iNum,iQuotedPrice,iUnitPrice,iTaxUnitPrice,iMoney,iTax,iSum,iDisCount,iNatUnitPrice, iNatMoney,iNatTax,iNatSum,iNatDisCount,iSettleNum,iSettleQuantity,iBatch,cBatch,bSettleAll,cMemo,cFree1,cFree2, RdsID, iTB, dVDate, TBQuantity, TBNum,iSOsID,iDLsID,KL,KL2,cInvName,iTaxRate,cDefine22,cDefine23,cDefine24,cDefine25,cDefine26,cDefine27,fOutQuantity,fOutNum,cItemCode,cItem_Class,cItemName,cItem_CName,fSaleCost,fSalePrice,iInvExchRate) Select DispatchList.DLID,UFDATA_003_2012..DispatchLists.iCorID,UFDATA_003_2012..DispatchLists.cWhCode,UFDATA_003_2012..DispatchLists.cInvCode,UFDATA_003_2012..DispatchLists.iQuantity,UFDATA_003_2012..DispatchLists.iNum,UFDATA_003_2012..DispatchLists.iQuotedPrice,UFDATA_003_2012..DispatchLists.iUnitPrice,UFDATA_003_2012..DispatchLists.iTaxUnitPrice,UFDATA_003_2012..DispatchLists.iMoney,UFDATA_003_2012..DispatchLists.iTax,UFDATA_003_2012..DispatchLists.iSum,UFDATA_003_2012..DispatchLists.iDisCount,UFDATA_003_2012..DispatchLists.iNatUnitPrice,UFDATA_003_2012..DispatchLists.iNatMoney,UFDATA_003_2012..DispatchLists.iNatTax,UFDATA_003_2012..DispatchLists.iNatSum,UFDATA_003_2012..DispatchLists.iNatDisCount,UFDATA_003_2012..DispatchLists.iSettleNum,UFDATA_003_2012..DispatchLists.iSettleQuantity,UFDATA_003_2012..DispatchLists.iBatch,UFDATA_003_2012..DispatchLists.cBatch,UFDATA_003_2012..DispatchLists.bSettleAll,DispatchList.cMemo,UFDATA_003_2012..DispatchLists.cFree1,UFDATA_003_2012..DispatchLists.cFree2, UFDATA_003_2012..DispatchLists.RdsID, UFDATA_003_2012..DispatchLists.iTB, UFDATA_003_2012..DispatchLists.dVDate, UFDATA_003_2012..DispatchLists.TBQuantity, UFDATA_003_2012..DispatchLists.TBNum,UFDATA_003_2012..DispatchLists.iSOsID,UFDATA_003_2012..DispatchLists.iDLsID,UFDATA_003_2012..DispatchLists.KL,UFDATA_003_2012..DispatchLists.KL2,UFDATA_003_2012..DispatchLists.cInvName,DispatchList.iTaxRate,UFDATA_003_2012..DispatchLists.cDefine22,UFDATA_003_2012..DispatchLists.cDefine23,UFDATA_003_2012..DispatchLists.cDefine24,UFDATA_003_2012..DispatchLists.cDefine25,UFDATA_003_2012..DispatchLists.cDefine26,UFDATA_003_2012..DispatchLists.cDefine27,UFDATA_003_2012..DispatchLists.fOutQuantity,UFDATA_003_2012..DispatchLists.fOutNum,UFDATA_003_2012..DispatchLists.cItemCode,UFDATA_003_2012..DispatchLists.cItem_Class, UFDATA_003_2012..DispatchLists.cItemName,UFDATA_003_2012..DispatchLists.cItem_CName, UFDATA_003_2012..DispatchLists.fSaleCost, UFDATA_003_2012..DispatchLists.fSalePrice,UFDATA_003_2012..DispatchLists.iInvExchRate FROM UFDATA_003_2012..DispatchLists INNER JOIN DispatchList ON UFDATA_003_2012..DispatchLists.DLID = DispatchList.DLID WHERE ISNULL(DispatchList.cVerifier,'')<>'' AND DispatchList.cVouchType='05' AND ISNULL(UFDATA_003_2012..DispatchLists.cWhCode,'')<>'' AND ISNULL(DispatchList.cSTCode,'')<>'' AND ISNULL(DispatchList.iSale,0)=0 AND NOT UFDATA_003_2012..DispatchLists.iDLsID IN (SELECT iDLsID FROM UFDATA_003_2013..DispatchLists) AND (CASE WHEN ISNULL(UFDATA_003_2012..DispatchLists.iNum,0) <>0 THEN (ABS(ISNULL(UFDATA_003_2012..DispatchLists.fOutQuantity,0))-ABS(UFDATA_003_2012..DispatchLists.iQuantity))*(ABS(ISNULL(UFDATA_003_2012..DispatchLists.fOutNum,0))-ABS(UFDATA_003_2012..DispatchLists.iNum)) ELSE ABS(ISNULL(UFDATA_003_2012..DispatchLists.fOutQuantity,0))-ABS(UFDATA_003_2012..DispatchLists.iQuantity) END) <>0
数据库跟踪如下,请大侠帮忙看一下哦 |
|