Skip to content

Instantly share code, notes, and snippets.

@christinebuckler
Last active October 30, 2023 16:17
Show Gist options
  • Save christinebuckler/515ed42a9cf4c6146d38dca1c63916fb to your computer and use it in GitHub Desktop.
Save christinebuckler/515ed42a9cf4c6146d38dca1c63916fb to your computer and use it in GitHub Desktop.
Loop over sql
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