WHILE
Translation reference to convert SQL Server While Statement to Snowflake Scripting
Description
The While statement allows an SQL statement or a block of statements to be repeatedly executed as long as the specified condition is true. The execution of statements in the WHILE loop can be controlled from inside the loop with the BREAK
and CONTINUE
keywords.
For more information for SQL Server While, check here.
Note: To define a statement block, use the control-of-flow keywords BEGIN
and END
.
Sample Source Patterns
Basic source pattern code
SQL Server
The following code refers to a While Loop in SQL Server that iterates the @Iteration variable and controls the flow of the loop to terminate when the value of @Iteration equals 10.
Statements after the CONTINUE
keyword will not be executed.
Snowflake Scripting
As well as SQL Server, in Snowflake Scripting the statements after the CONTINUE
keyword will not be executed.
Notice that in Snowflake Scripting it is not necessary to use the BEGIN and END keywords to define a statement block, however it can be used if required.
While with empty body Source Pattern
SQL Server
Please note this example was written while the IF ELSE statement was not supported, the differences in the results should disappear when support for the statement is implemented.