You can process in loops using the WHILE statement. In twenty years, I think I have used WHILE ONCE. I can usually find a better solution than using WHILE.
Incrementing An Index Value
USE demo
DECLARE @i TINYINT = 1
WHILE @i < 10 BEGIN
PRINT 'The variable''s value is ' + CAST(@i AS NVARCHAR(1)) + '.'
SET @i = @i + 1
END
Copyright © 2020, Mass Street Analytics, LLC. All Rights Reserved.