解决方案: |
经查您的数据,现对问题做如下分析答复: 造成该现象的原因是在订单子表(so_sodetails)中,正常情况下isosid应同autoid,即便由于某些原因,与autoid不同,但至少不能有重复的记录,即两个订单表体行不能有相同的标识。而该数据中恰发生此问题。由于isosid字段会在dispathlist/s、salebillvouch/s表中进行记录,相同的isosid对应一张发货或发票记录,从而导致对订单操作时,正常连接的单据无法查询获取,提示异常的错误。故,需要将该类订单表体行的isosid根据发货单和发票表、重新取值。具体的脚本如下,可参考执行,同时,已将脚本发送邮件给您,请注意查收: declare @autoid varchar(50) declare @string varchar(200) declare UpdateSoDetailsIsosid cursor for select autoid from so_sodetails where csocode not in (select isnull(cSOCode,'') from dispatchlist ) and isosid in (select isnull(isosid,'') from dispatchlist ) and isosid in (select isosid from so_sodetails group by isosid having count(*)>1) --order by isosid union select autoid from so_sodetails where csocode not in (select isnull(cSOCode,'') from salebillvouch ) and isosid in (select isnull(isosid,'') from salebillvouch ) and isosid in (select isosid from so_sodetails group by isosid having count(*)>1) --order by isosid) for read only Open UpdateSoDetailsIsosid Fetch next from UpdateSoDetailsIsosid into @autoid while @@Fetch_Status = 0 begin --print @isosid set @string = 'update so_sodetails set isosid =(select max(isosid) from so_sodetails)+1 where autoid = ' + @isosid --print @string exec (@string) set @string = 'update so_sodetails set ikpquantity=0,ikpmoney=0 ,ifhnum=0,ifhquantity=0,ifhmoney=0 where autoid = ' + @isosid exec (@string) Fetch next from UpdateSoDetailsIsosid into @autoid end close UpdateSoDetailsIsosid DEALLOCATE UpdateSoDetailsIsosid |