CONTINUE command in SQL Server
The CONTINUE command is used to give command execution authority to the last expression of the loop. That means upside-down to the top of the loop, all the commands that follow in the loop containing CONTINUE will be ignored without execution. This article will detail how to use this command in SQL Server.
Syntax
To use the CONTINUE statement in SQL Server, we use the following syntax:
TIẾP TỤC;
Note:
- There are no parameters and arguments in the CONTINUE statement.
- You use the CONTINUE statement to return to the WHILE loop and execute its subsequent conditions.
For example
DECLARE @Number INT = 1;
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
4 ★ | 1 Vote
You should read it
May be interested
- The command bootcfg delete in Windowsthe bootcfg delete command deletes the operating system entry in the [operating systems] section of the boot.ini file. the command applies to: windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012.
- The route_ws2008 command in Windows(applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012)
- Ntcmdprompt command in Windows(applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012).
- Nslookup command in Windows(applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012).
- The ntfrsutl command in Windows(applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012).
- Prnqctl command in Windows(applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012)
- Prnport command in Windows(applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012)
- Prnmngr command in Windows(applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012)
- The prnjobs command in Windows(applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012)
- Prndrvr command in Windows(applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012)