sql server for loop 1

sql server for loop

DECLARE @cnt INT = 0;

WHILE @cnt < cnt_total
   SET @cnt = @cnt + 1;

Here is what the above code is Doing:
1. Declare a variable @cnt and set it to 0.
2. While @cnt is less than cnt_total, execute the statements in the loop.
3. Increment @cnt by 1.
4. Repeat steps 2 and 3 until @cnt is no longer less than cnt_total.

Similar Posts