How can I modify a maintenance plan in SQL Server 2008 using a T-SQL script?
I want to change the schedule of a maintenance plan and change the path of the .bak
file .
All these changes should be done using a T-SQL script.
maintenance-planssql serversql-server-2008t-sql
How can I modify a maintenance plan in SQL Server 2008 using a T-SQL script?
I want to change the schedule of a maintenance plan and change the path of the .bak
file .
All these changes should be done using a T-SQL script.
Best Answer
There are 2 parts to this question, I'll treat them one by one.
Modifying the schedule
Modifying the schedule isn't really changing the maintenance plan as much as changing the SQL Agent schedule.
Have a look at sp_update_schedule for this need.
Modifying the Maintenance plan itself
This will be hard using pure T-SQL as the maintenance plan is stored as an SSIS package. You will have to resort to CLR integration for this.
If you want to do that you would have to export the package from the SSIS package store. (see here) and then modify them through c#.
See Building Packages Programmatically and Modifying an SSIS Package through code