Creating a date dimension or calendar table in SQL Server
Creating a date dimension or calendar table in SQL Server By: Aaron Bertrand | Updated: 2020-04-06 | Comments (83) | Related: 1 | 2 | 3 | 4 | 5 | More > Dates Problem A calendar table can be immensely useful, particularly for reporting purposes, and for determining things like business days between two dates. I often see people struggling with manually populating a calendar or date dimension table; usually there are lots of loops and iterative code constructs being used. In this tip I will show you how to build and use a calendar table using a set-based solution that is powerful and easily customizable. Solution I build calendar tables all the time, for a variety of business applications, and have come up with a few ways to handle certain details. Sharing them here will hopefully prevent you from re-invent...