VistaDB 5
WHILE / BREAK / CONTINUE
WHILE, BREAK, and CONTINUE are SQL control of flow statements allowing looping and controlled loop execution.

WHILE

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...CONTINUE

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
See Also