While loop: The while loop uses to when we want to get looping by each value. We can use the condition in this loop. This loop similar to other programming language but there is some manure deferent. Now given bellow the example code:
DECLARE @Counter INT SET @Counter=1 WHILE ( @Counter <= 10) BEGIN PRINT 'The counter value is = ' + CONVERT(VARCHAR,@Counter) SET @Counter = @Counter + 1 END
We print the value and text in 10 time by given the condition under while block.