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
Latihan ini merupakan bagian dari kursus
Intermediate SQL Server
Instruksi latihan
Write a WHILE loop that increments counter by 1 until counter is less than 30.
Latihan interaktif langsung praktik
Cobalah latihan ini dengan melengkapi kode contoh ini.
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