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:

  1. There are no parameters and arguments in the CONTINUE statement.
  2. 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

May be interested

  • The command bootcfg delete in WindowsThe command bootcfg delete in Windows
    the 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 WindowsThe 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 WindowsNtcmdprompt command in Windows
    (applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012).
  • Nslookup command in WindowsNslookup command in Windows
    (applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012).
  • The ntfrsutl command in WindowsThe ntfrsutl command in Windows
    (applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012).
  • Prnqctl command in WindowsPrnqctl command in Windows
    (applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012)
  • Prnport command in WindowsPrnport command in Windows
    (applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012)
  • Prnmngr command in WindowsPrnmngr command in Windows
    (applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012)
  • The prnjobs command in WindowsThe prnjobs command in Windows
    (applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012)
  • Prndrvr command in WindowsPrndrvr command in Windows
    (applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012)