Allows looping in TSQL code until a Boolean False condition is received. Each WHILE block must be contained in a BEGIN/END block.
While Example |
Copy Code
|
---|---|
DECLARE @Count Int; SET @Count = 0; WHILE @Count < 100 BEGIN SET @Count = @Count +1 END |
BREAK and CONTINUE are used to exit, or continue executing WHILE statements.
Break... Continue Example |
Copy Code
|
---|---|
DECLARE @Count Int; SET @Count = 0; WHILE @Count < 100 BEGIN SET @Count = @Count +1 IF @Count > 10 BREAK; ELSE CONTINUE; END |