Hi @Nandan Hegde
Please also check this script using while loop:
DECLARE @i INT,@sum INT
SET @i=1
SET @sum=0
WHILE @i<=100
BEGIN
SET @sum=@sum+@i
SET @i=@i+1
END
SELECT @sum
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.