In the middle of each month, our system puts the most recent data in a NEXT database, then at the beginning of the next month NEXT is put into CURRENT and NEXT is emptied.
I want my query to always use the most up-to-date database, or from the first to the 20th use CURRENT, thereafter use NEXT. I've tried to do this with a CASE statement, but I keep getting syntax errors.
Here's a sample of the query that failed:
Expand|Select|Wrap|Line Numbers
- SELECT stuff.id
- FROM
- case when day(getdate())>19 then CURRENT.dbo.facts
- else NEXT.dbo.facts
- end
- as stuff
Thanks,
Dante