I recently transferred a sql server maintenance plan from one server to another. When I tried to delete it I got a non descriptive error An error was encountered when trying to remove the package “maintenance Plans\blah blah” from SQL Server. In order to delete it I needed to walk the hierarchy of the maintenance plans system tables. The following script will do this.
Declare @maintid varchar(100)
set @maintid = (select id from msdb..sysmaintplan_plans where name = 'testplan')
delete from sysmaintplan_log where plan_id = @maintid
delete from sysmaintplan_subplans where plan_id = @maintid
delete from sysmaintplan_plans where id = @maintid
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment