delete from AAA a where exists (select 1 from AAA where autoid<a.autoid and cBusType=a.cBusType and VouCode=a.VouCode and ID=a.id and dVouDate=a.dVoudate and dKeepDate = a.dkeepdate and iMonth=a.imonth and CinvCode=a.cinvcode and iAInQuantity =a.iainquantity and iAOutQuantity=a.iaoutquantity)

解决方案 »

  1.   

    --楼主做delete前最好把表备份一把.
    --这样行不
    delete from AAA  where AutoID not in 
    (
    select min(AutoID),cBusType,cVouCode,ID,dVouDate,dKeepDate,iMonth,CinvCode,iAInQuantity,iAOutQuantity group by cBusType,cVouCode,ID,dVouDate,dKeepDate,iMonth,CinvCode,iAInQuantity,iAOutQuantity
    )
      

  2.   

    mgsray(我是新新新新,新来的吧) :
    delete from AAA a where exists (select 1 from AAA where autoid<a.autoid and cBusType=a.cBusType and VouCode=a.VouCode and ID=a.id and dVouDate=a.dVoudate and dKeepDate = a.dkeepdate and iMonth=a.imonth and CinvCode=a.cinvcode and iAInQuantity =a.iainquantity and iAOutQuantity=a.iaoutquantity)
    服务器: 消息 170,级别 15,状态 1,行 1
    第 1 行: 'a' 附近有语法错误。但是选择却没有错:
    SELECT * from AAA a where exists (select 1 from AAA where autoid<a.autoid and cBusType=a.cBusType and VouCode=a.VouCode and ID=a.id and dVouDate=a.dVoudate and dKeepDate = a.dkeepdate and iMonth=a.imonth and CinvCode=a.cinvcode and iAInQuantity =a.iainquantity and iAOutQuantity=a.iaoutquantity)
      

  3.   

    这样就对了~!DELETE FROM AAA
    where AutoID IN(SELECT AutoID from AAA a where exists (select 1 from AAA where autoid<a.autoid and cBusType=a.cBusType and VouCode=a.VouCode and ID=a.id and dVouDate=a.dVoudate and dKeepDate = a.dkeepdate and iMonth=a.imonth and CinvCode=a.cinvcode and iAInQuantity =a.iainquantity and iAOutQuantity=a.iaoutquantity)
    )