Last active
October 30, 2023 16:17
-
-
Save christinebuckler/515ed42a9cf4c6146d38dca1c63916fb to your computer and use it in GitHub Desktop.
Loop over sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @SomeTempTable table | |
( | |
Column1, | |
Column2 | |
) | |
declare @FiscalWeek int = 1 | |
declare @FinalWeek int = ? | |
while @FiscalWeek <= @FinalWeek | |
begin | |
insert into @SomeTempTable | |
select something from somthing where FiscalYear = 2022 and FiscalWeek = @FiscalWeek | |
set @FiscalWeek = @FiscalWeek + 1 | |
end | |
select * from @SomeTempTable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment