BREAK
exits the innermost WHILE loop
What changes
- Input
- none
- Output or change
- none
Syntax at a glance
BREAK
Work example
A controlled task needs the behavior documented for BREAK before it is added to a batch.
Read the linked Microsoft syntax and test BREAK with synthetic input in an isolated database. Record its scope, permissions, and error path.
Check your work The loop stops on its third iteration. StoppedAt is 3.
Practice SQL
Open in SQL FlowDECLARE @Step int = 0;
WHILE @Step < 6
BEGIN
SET @Step = @Step + 1;
IF @Step = 3 BREAK;
END;
SELECT @Step AS StoppedAt;
Open Microsoft Learn for full syntax, permissions, and details for your version.