解决方案: |
存在ap_detail表中有记录,而在ap_closebill/s表中不存在的情况。具体可通过如下脚本查找。查找后,需要与用户核对,是否这些单据可以删除?如果不能删除,需要手工在库里补录,但不能确保记录没有问题。请用户考虑选择。脚本如下: --1.查询ap_detail表中的记录 SELECT cCoVouchType As cVouchType,cCoVouchID As cVouchID,iCoClosesID As iClosesID,max(a.dVouchDate) AS dVouchDate,cDwCode,max(a.cDeptCode) AS cDeptCode, max(a.cPerson) AS cPerson,Max(convert(int,bPrepay)) As bPrepay,Max(a.cCode) As cCode,Max(a.cItem_Class) As cItem_Class, Max(a.cItemCode) As cItemCode,Max(cItemName) as cItemName,max(a.cDigest) AS cDigest,max(a.cexch_name) AS cexch_name,max(a.iExchRate) As iExchRate, Sum(iDAmount_f-iCAmount_f) AS iDA_f,0 As iCA_f,Sum(iDAmount-iCAmount) AS iDA,0 As iCA,Sum(iDAmount_s-iCAmount_s) AS iDA_s,0 As iCA_s, max(a.cSSCode) As cSSCode,max(cOrderNo) As cNoteNo,max(a.cFlag) As cFlag, Max(cDefine1) As Def1,Max(cDefine2) As Def2,Max(cDefine3) As Def3, Max(cDefine4) As Def4,Max(cDefine5) As Def5,Max(cDefine6) As Def6, Max(cDefine7) As Def7,Max(cDefine8) As Def8,Max(cDefine9) As Def9, Max(cDefine10) As Def10,Max(cDefine11) As Def11,Max(cDefine12) As Def12, Max(cDefine13) As Def13,Max(cDefine14) As Def14,Max(cDefine15) As Def15, Max(cDefine16) As Def16,Max(cContractType) as cConType,Max(cContractID) as cConID into tempapdetail FROM Ap_Detail As a Where iFlag<>0 OR Sum(iDAmount-iCAmount)<>0 Order By cCoVouchType,cCoVouchID,iCoClosesID --2.查找在ap_closebill表中缺少的记录 select * from tempapdetail where (cvouchid not in (select cvouchid from ap_closebill where (cvouchtype = '49' and cflag = 'ap' )) and cvouchtype = '49') or (cvouchid not in (select cvouchid from ap_closebill where (cvouchtype = '48' and cflag = 'ap' ) ) and cvouchtype = '48') |