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
No comments:
Post a Comment