pętla za pośrednictwem zmiennej tabeli w TSQL bez użycia kursora

Declare @Id int
While (Select Count(*) From ATable Where Processed = 0) > 0
Begin
    Select Top 1 @Id = Id From ATable Where Processed = 0
    --Do some processing here
    Update ATable Set Processed = 1 Where Id = @Id 
End
Code with bulbul