Creating a WHILE loop
In this exercise, you will use the variable you created in the previous exercise you write a WHILE loop. Recall that structure:
WHILE some_condition
BEGIN
-- Perform some operation here
END
Questo esercizio fa parte del corso
Intermediate SQL Server
Istruzioni dell'esercizio
Write a WHILE loop that increments counter by 1 until counter is less than 30.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
DECLARE @counter INT
SET @counter = 20
-- Create a loop
___
-- Loop code starting point
___
SELECT @counter = @counter + 1
-- Loop finish
___
-- Check the value of the variable
SELECT @counter