Calculating the columns required for a date dimension using T-SQL is a pretty common request from SQL Server developers. So we decided to make it really easy to do. In our free SDU Tools for developers and DBAs, there is a table-valued function called DateDimensionColumns, for just this purpose.
You supply a date, and the month that your financial year starts in, and it supplies the output columns.
You can also easily combine it with our DatesBetween function to get dimension columns for a range of dates:
You can see it in action here:
To become an SDU Insider and to get our free tools and eBooks, please just visit here: