• There is actually another way to archive a row by row processing. I am using it in different scenarios since quite a few years and it turned out to be very efficient.

    BEGIN

    Declare @ID int

    Select @ID = Min(ID) from emp

    WHILE @ID Is Not Null

    BEGIN

    UPDATE emp SET salary = (salary * 115) /100 WHERE emp.id = @ID

    Select @ID = Min(ID) from emp where ID > @ID

    END

    END

    In relation to the actual performance of this method I listed the times/cost on my server below. Please note that I also included the cost calculated by the execution plan:

    READESTIMATED EXECUTION COST

    Direct SQL50.0132935 100%

    Cursor690.14620601099%

    Temp table with TOP2540.25310071904%

    Temp table with IDENTITY column1210.0994881 748%

    Min Loop390.0861955 648%

    🙂