I'm certain I'm overlooking something very basic here but I can't wrap my head around it after querying and googling for about an hour.
I have a datetable already in existence, if that helps. It is populated with this past years' worth of dates and is updated nightly via a stored proc that gets run by a job on the server.
What I need to do is pull Monday-Sunday weeks out so I can properly join them to a tracking table to get a weekly hit graph up. I don't want to write out 52 gradually larger select statements and union them for obvious reasons, and I don't like the idea of cursors.
I've already done this with months and days but the nature of the weeks confuses me for some reason, or it's inherently different.
Any thoughts on how to automate the process without cursors or a huge select/union? I'll go for the cursor and dump it into a table nightly if absolutely necessary but I hope not.
FYI my desired format at the end of it would be:
[Week number] | [StartDate] | [EndDate]
For each week