I have to maintain an old MS SQL 2008 database with tons of records. I notice that about 90% are duplicates.
So what is the best way to remove only the duplicates.
I used...
SELECT [Col1],[Col2],[Col3],[Col...], COUNT(*) AS [DuplicateCount]
FROM myTable
GROUP BY [Col1],[Col2],[Col3],[Col...]
HAVING COUNT(*) > 1;
to find the duplicates but I struggle how to delete all of them but not the first one. I found some hints with using TOP but not in combination with group by. Sorry but my SQL is too bad for that ;)
Thanks in advance!!!