How to use While Loop in SQL Server stored procedure??

Leave a Comment

I will explain how to use while loop in SQL Server stored procedure. To use While Loop in stored procedure you need to write query like this

DECLARE @loop INT
SET @loop = 0
WHILE @loop <= 10
BEGIN   
SET @loop = @loop + 1   
PRINT @loop
END
If you run above query you will get output as shown below.


OUTPUT :


0 comments:

Post a Comment