Oracle Sql While Loop. While loop statement works similar to the basic loop statement except the exit condition is at the very beginning of the. Set @counter = @counter + 1.

In sql server, while loop can be used in similar manner as any other programming language. The condition is tested each pass through the loop. Use a while loop when the condition test is required at the start of the loop.