Wednesday, May 28, 2008

Great duplicate removal query...

This is a great query to replace duplicates within a table, the define characteristics are comapring a series of fields that should be the same and then using the unique ID identifier between the table aliases A and B so that you only delete the greater ID. In doing this you will leave the lowest ID giving you one unique row the lowest ID row. Very Great!

delete Table_1 A
where exists
(select * from Table_1 B where A.field_1 = B.field_1 and A.field_2 = B.field_2 and A.field_3 = B.field_3 and A.field_4 = B.field_4 and >

No comments: