好记性不如烂笔头。

SQL删除重复数据,保留一条数据

DELETE  FROM #table
WHERE   EXISTS ( SELECT node ,
                        mailNo
                 FROM   #table b
                 WHERE  #table.node = b.node
                        AND #table.mailNo = b.mailNo
                 GROUP BY node ,
                        mailNo
                 HAVING COUNT(1) > 1 )
        AND id NOT IN ( SELECT    MIN(a.id)
                              FROM      #table a
                              WHERE     #table.node = a.node
                                        AND #table.mailNo = a.mailNo
                              GROUP BY  node ,
                                        mailNo
                              HAVING    COUNT(1) > 1 );