I want to add a primary key to a table with some duplicates and I have to get rid of them first, keeping the first row from each duplication case.
Say I found a case of duplication where there are 5 rows with t1.id=3. Other columns may be identical or not (I cannot count on it).
I'm looking for something like
delete top (5) * from t1 where not exists (select top (1) * from t1 where t1.id=3)
I'm looking for a solution that will not involve using creating additional identity column or copying to a table with this primary key set because this table may have huge amount of rows, and these options are too time consuming.