Finding and Deleting Duplicate Records
INF: How to Remove Duplicate Rows From a Table
SELECT col1, col2, count(*)
FROM t1
GROUP BY col1, col2
HAVING count(*) > 1
SELECT col1, col2, col3=count(*)
INTO holdkey
FROM t1
GROUP BY col1, col2
HAVING count(*) > 1
DELETE t1
FROM t1, holdkey
WHERE t1.col1 = holdkey.col1
AND t1.col2 = holdkey.col2
INSERT t1 SELECT * FROM holdkey
October 5, 2005 | Comments
Jan Ole Peek's Blog by is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 Canada License. 2005 - 2010. Entries and comments feeds.





