Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #loop #table #variable #TSQL #cursor
ADD COMMENT
Topic
Name
1+8 =