DECLARE @Total INT = 0;
@Number WHILE <= 10
BEGIN
IF @NUMBER = 5
BREAK;
ELSE
SET @Total = @Total + @Number;
SET @Number = @Number + 1;
TIẾP TỤC;
END;
END;
PRINT @Total;
GO
In this example using the CONTINUE statement, we will restart the WHILE loop if the variable @NUMBER is different from 5 as specified by the IF . ELSE statement.
Previous article: BREAK (Control Interrupt) command in SQL Server
Next lesson: GOTO command in SQL Server