• I agree that cursors are a drag on performance but what a way to go about avoiding them! A Count(*) and a delete for every row of the table, REALLY?

    You can achieve the same effect far more efficiently by declaring a temporary table with an Identity column as Primary Key. Then all you need to do is increment a variable and do select where Id = @Iterator, you can test @@Rowcount or value IS NULL to manage the loop.