What's the best way to get a view dynamically depending on the month?
I have 12 views setup, each representing a month. (Jan, Feb, etc)
This is my first attempt but it doesn't seem like the best solution.
Code:
declare @currentdate int
set @currentdate = month(getdate())
IF @currentdate = 1
select * from dbo.JAN_V
ELSE IF @currentdate = 2
select * from dbo.FEB_V
ELSE IF @currentdate = 3
select * from dbo.MAR_V
ELSE IF @currentdate = 4
select * from dbo.APR_V
ELSE IF @currentdate = 5
select * from dbo.MAY_V
ELSE IF @currentdate = 6
select * from dbo.JUN_V
ELSE IF @currentdate = 7
select * from dbo.JUL_V
ELSE IF @currentdate = 8
select * from dbo.AUG_V
ELSE IF @currentdate = 9
select * from dbo.SEPT_V
ELSE IF @currentdate = 10
select * from dbo.OCT_V
ELSE IF @currentdate = 11
select * from dbo.NOV_V
ELSE IF @currentdate = 12
select * from dbo.DEC_V
Thanks a bunch!