Reputation: 2097
Say my start year is 2000 and I would like to have a one column select return every year from 2000 to the current year, example:
2000
2001
...
2012
2013
This is to populate a parameter in Reporting Services.
Upvotes: 0
Views: 60
Reputation: 247880
The easiest thing for you to do would be to create a numbers table that you would use for these types of queries.
You could also use a recursive Common Table Expression to generate the list of years:
;with cte (yr) as
(
select 2000
union all
select yr + 1
from cte
where yr+1 <=2013
)
select yr
from cte;
Upvotes: 2