I have a query which finds duplicate IDs
SELECT uniqueID2, count(uniqueID2) as 'count'
FROM gpDetailAfterMultiplier
group by uniqueID2
having count(uniqueID2) > 1
this produces an output something like:
uniqueID2 count
111111111 2
111111112 2
111111113 2
111111114 2
How do I automatically delete one of the two duplicates?
I can do this one at a time by doing
DELETE top(1) from gpDetailAfterMultiplier where UniqueID2 = '111111111'
is there any way to do this so that it automatially 'loops' through each result and deletes one of the two duplicates for each unique id?