I’d like to make a query that shows the current month in text form and then the rest of the year printed on the following rows until all months for the year have been printed.
This is somewhat hard to explain so I’ve made the following example. I know the following code is ridiculous but this is the only way I know to do this with my current skill level. Ideally I would also like months to be converted from printing an integer to print the character value of the month (so 1 would be January). I know I could do this with a case/when but I’m sure there’s a better way that I haven’t been exposed to yet.
declare @currentmonth as int = datepart(month, getdate())
select
@currentmonth
union
select
@currentmonth +1
union
select
@currentmonth +2
union
select
@currentmonth +3
union
select
@currentmonth +4
union
select
@currentmonth +5
union
select
@currentmonth +6
union
select
@currentmonth +7
union
select
@currentmonth +8
union
select
@currentmonth +9
union
select
@currentmonth +10
union
select
@currentmonth +11
In SQL Server 2008+ you can use this