Answers for "loop through a table variable in TSQL without using a cursor"

SQL
0

loop through a table variable in TSQL without using a cursor

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
Posted by: Guest on August-05-2021

Code answers related to "loop through a table variable in TSQL without using a cursor"

Code answers related to "SQL"

Browse Popular Code Answers by Language