If we execute following sql query:
DECLARE @Num AS INT = 5
IF @Num < 5
CONTINUE
SELECT 1
We will get error message :
Cannot use a CONTINUE statement outside the scope of a WHILE statement.
Cause: In sql server, keyword CONTINUE is part of WHILE loop. We
must have to use CONTINUE keyword inside a WHILE loop. For example:
DECLARE @Num AS INT = 10
WHILE @Num > 0 BEGIN
SET @Num =
@Num - 1
IF @Num %
2 = 0 BEGIN
CONTINUE
END ELSE
SELECT @Num
END
No comments:
Post a Comment