I decided I needed to do something else other than just send an email notification, I needed to take corrective action when it occurred. So I wrote a little stored procedure that will take the ALTER DATABASE statement as a parameter, parse it and take the appropriate corrective action.
Simple enough, right? Now I just need to add the call to my newly created stored procedure in my server level trigger and we are good to go. But wait, you can’t ALTER a database within an ALTER DATABASE statement (don’t believe me? Use this as a learning exercise to see what happens when you try). So what could I do? There are several things you could do, but I chose to create a table that could hold this newly created ALTER DATABASE statement and insert the record there. Then I created a SQL Agent job that runs once every hour and reads that table and executes any entries it finds, then deletes them after successfully executing.
Read the whole thing, including the disclaimer.