• Sean Lange (1/23/2015)


    Oh the cursors are unbelievably stuipd. They are used to count!!!

    set @Counter = 1

    while exists(select * from StupidlyLargeHeap (nolock) where someColume = @Counter) begin

    set @Counter = @Counter + 1

    end

    It must be a way of thinking - I worked at a place where very similair code was used to make a count of certain rows, and then the count was merely checked for > 0. Replaced it with EXISTS. And the really sad thing was the Developer who wrote it had said I'd never find a way to optimise the code.