I'm using SSMS 2012 and trying to figure out a way to write a query so that my database name will adjust to the second to most current month.
We have billing databases for every month that go like BillingMonth01206
and BillingMonth022016
, as well as one called BillingMonthLM
for "Last Month". The LM database is nice as we do not have to constantly change databases for last month's data, but I always need the one before that. So as it is now September, I need July billing (BillingMonth072016).
I have been doing a find and replace every month, but is there a way to automatically configure this? Maybe using a string or something?