SQL找出和删除一个表的重复记录

 

Code
SELECT Column1, Column2,Column3,Column4 FROM T_Table GROUP BY Column1, Column2 ,Column3,Column4 HAVING Count(1)>1

DELETE T_Table
WHERE  Id IN (SELECT a.Id
                  
FROM   T_Table  a
                  
WHERE  EXISTS (
                            
SELECT b.Id
                            
FROM   T_Table  b
                            
WHERE  b.Column1 = a.Column1
                              
AND  b.Column2 = a.Column2
                              
AND  b.Column3 = a.Column3
                              
AND  b.Column4 = a.Column4
                              
AND  b.Id<a.Id
                         ))
posted @ 2009-05-06 16:30  KenBlove  阅读(592)  评论(0编辑  收藏  举报