Sql CONTINUE STATEMENT,how to use

CONTINUE STATEMENT IN SQL DATABASE:



In this Post we learn how to use the CONTINUE statement in SQL Server with Example and also describe Example.

SQL CONTINUE STATEMENT DESCRIPTION:

In SQL Server, the CONTINUE statement is used when you are want a WHILE LOOP to execute again. It will ignore any statements after the CONTINUE statement.

SQL CONTINUE STATEMENT SYNTAX:

The syntax for the CONTINUE statement in SQL Server  is:

     CONTINUE;

Parameters or Arguments in CONTINUE STATEMENT:

  • There are no parameters or arguments for the CONTINUE statement.
  • You use the CONTINUE statement to restart a WHILE LOOP and execute the WHILE LOOP body again from the start.


SQL CONTINUE STATEMENT EXAMPLE:

See an example that represent how to use the CONTINUE statement in SQL Server
For example:

DECLARE @value INT;
SET @value = 0;
WHILE @ value <= 10
BEGIN
   IF @ value = 3
      BREAK;
   ELSE
   BEGIN
      SET @value = @value + 1;
      PRINT 'Inside WHILE LOOP’;
      CONTINUE;
   END;
END;
PRINT 'Done WHILE LOOP';
GO


In this Example of CONTINUE statement, we will restart the WHILE LOOP if the variable @value is not equal to 3.



Sql Server Related Qus:

Asp.net Related Post:


Comments

Popular posts from this blog