Eirikur Eiriksson (9/13/2014)
Jeff Moden (9/12/2014)
The following should do it (see attached). I made sure that it's a high performance iTVF instead of an mTVF. I also got rid of the resource hungry, performance robbing recursive CTE that counts and added a column to return the number of days in each week. Of course, you can remove that column if you'd prefer it not to be there.Nice one Jeff, is there a spackle coming?
😎
Thanks, Eirikur, especially for the idea of Spackling this. I suppose I could expand on it a bit to include multiple months to make it more useful. Actually, come to think of it and except for a modernization of technique, it's mostly written from a post I did on another site back in 2007. Add a week number to each row and it's mostly done.
https://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1173&lngWId=5
--Jeff Moden
Change is inevitable... Change for the better is not.