Tuesday 6 January 2015

Removing Duplicates in a table

Rather unfortunate misapplication of OR in a WHERE clause led to a table containing duplicate entries. To remove them, I used the following: Delete x from ( select *, rn=row_number() over (partition by columnA order by columnB) from TABLE ) x where rn > 1;

No comments:

Post a Comment