I'm setting up a maintenance plan on Sql Server.
I want to add an Execute T-SQL Statement Task to the plan, however I do not see any way to set this task to run in every [user|system|all] database as you can with pretty much every other task type.
Is there a way to do this, perhaps with an "in-place" parameter in the script that would be used to substitute the database name?
I want to run a nightly script in the maintenance plan, but it needs to be able to put the database name in the script.
Should I call a stored procedure from the maintenance plan that iterates through all the databases desired using dynamic SQL to execute my statement?


SET TO SIMPLE; SHRINKFILE; SET TO FULL, but I want to be able to code it to all user databases, not hardcoded, so that when we add new databases, we don't need to manually add them to the script. – eidylon Sep 4 '12 at 15:26