Repeatedly executes the provided statements as long as the
condition expression evaluates to the integer 1.
The loop may be terminated without regard to the expression by using the
BREAKstatement. The loop may be restarted by using the
- condition (integer, 0 or 1)
If this expression evaluates to 1, then the stmt statements are executed. Otherwise, the loop is terminated.
- stmt (statement)
The statements to execute if the condition is 1. If more than one stmt is desired, the
ENDkeywords must be used.
DECLARE @counter = 1;
WHILE @counter <= 10 BEGIN
SET @counter = @counter + 1;
Prints the numbers 1 to 10 in increasing order.