We have requirement where 2 months and 2 years are provided as input. And the result should provide a comma separated month-year all the months between the from month-year and to month-year.
Say, we have
From Month is 'Jan'
From Year is 2011
To Month is 'Apr'
To Year is 2011
desired output
Jan'11,Feb'11,Mar'11,Apr'11
Can this be achieved using recursive CTE? We need to achieve this using recursive CTE. Could somebody help me on this.
Try this code:
Result:
Test here:
https://data.stackexchange.com/stackoverflow/q/114801/declaration-of-variables