Thursday 23 June 2016

How to Use the GoTo statement in SQL SERVER

In This post we are going to see how to use the goto statement in SQL SERVER.


Goto statement causes the program control to unconditionally jump to the label specified in the GOTO statement.
           
DECLARE @i INT =1
WHILE(@i < 8)
BEGIN

      IF @i%4=0
      GOTO outofloop;
      ELSE
      GOTO Incr;

      Outofloop:
      BREAK;

      Incr:
      PRINT @i
      SELECT @i+=1

END

Output:
1
2




From this post you can learn how to use the GOTO statement in SQL SERVER.


No comments:

Post a Comment