delete from 
from osrd a
where a.myid != 
(select max(myid) from osrd b where b.ItemCode=a.ItemCode and b.DocType=a.DocType and b.DocEntry=a.DocEntry and b.DocLineNum=a.DocLineNum)错误信息:
服务器: 消息 156,级别 15,状态 1,行 2
在关键字 'from' 附近有语法错误。

解决方案 »

  1.   

    delete from  osrd a
    where a.myid != 
    (select max(myid) from osrd b where b.ItemCode=a.ItemCode and b.DocType=a.DocType and b.DocEntry=a.DocEntry and b.DocLineNum=a.DocLineNum)
      

  2.   

    delete from 
    from osrd a两个from ,笔误?
      

  3.   

    try
    delete  a
    from osrd a
    where a.myid != 
    (select max(myid) from osrd b where b.ItemCode=a.ItemCode and b.DocType=a.DocType and b.DocEntry=a.DocEntry and b.DocLineNum=a.DocLineNum)
      

  4.   

    多了個from ,將前面的那個from改為a
      

  5.   

    笔误条! 原来什么也没有也执行不过,改为a 就OK了,谢谢各位
      

  6.   

    用exists应该效率会好一点:
    delete a from 
    from osrd a
    where exists
    (select max(myid) from osrd b where b.ItemCode=a.ItemCode and b.DocType=a.DocType and b.DocEntry=a.DocEntry and b.DocLineNum=a.DocLineNum and myid>a.myid)