Quantcast
Channel: Marc Valk dot NetMarc Valk dot Net » SQL Server
Viewing all articles
Browse latest Browse all 4

SQL: maintenance plan delete after server rename

$
0
0

In a previous post I spoke about changing your database server name. If you created a maintenance plan, you might notice that the plan will fail. This is because the connection of your maintenance plan could be changed.

You can delete the maintenance plan by executing the following T-SQL (just change the Maintenance plan name:

BEGIN TRAN DeleteOldMaintenancePlans

SELECT @PlanID = id
FROM sysmaintplan_plans
WHERE name LIKE ‘MaintenancePlan Name’

DELETE FROM sysmaintplan_log
WHERE plan_id = @PlanID

DELETE FROM sysmaintplan_subplans
WHERE plan_id = @PlanID

DELETE FROM sysmaintplan_plans
WHERE id = @PlanID

IF @@ERROR = 0
COMMIT TRAN DeleteOldMaintenancePlans
ELSE
ROLLBACK TRAN DeleteOldMaintenancePlans

GO

After this you can manually delete the job which was associated with the maintenance plan.

Thx to SQLLearnings


Viewing all articles
Browse latest Browse all 4

Trending Articles