sqlrx logo
SQLRx® Tip of the Month
 

July 2011
SQL 2008     

SQL Server Administration Remove maintenance plans left after a server rename.  Many times when upgrading SQL Server or migrating to new hardware, it is necessary to rename the server when it's ready to be used as production.  However, if any maintenance plans created before the server was renamed are still present after the rename, you may find that trying to delete the old jobs results in error 547 (below).

 

Drop failed for Job 'User Databases - Full Daily Backup.Subplan_1'. (Microsoft.SqlServer.Smo)

The DELETE statement conflicted with the REFERENCE constraint "FK_subplan_job_id". The conflict occurred in database "msdb", table "dbo.sysmaintplan_subplans", column 'job_id'.
The DELETE statement conflicted with the REFERENCE constraint "FK_subplan_schedule_id". The conflict occurred in database "msdb", table "dbo.sysmaintplan_subplans", column 'schedule_id'.
The statement has been terminated.
The statement has been terminated. (Microsoft SQL Server, Error: 547)

_________________________________________________________________________ 

 

Here are the steps to correct the problem:

 

-- Find the maintenance plan name and id that you want to delete.

-- Write down the id of the one you want to delete.

SELECT name, id FROM msdb.dbo.sysmaintplan_plans

 

-- Place the id of the maintenance plan you want to delete

-- into the below query to delete the entry from the log table

DELETE FROM msdb.dbo.sysmaintplan_log WHERE plan_id = '<<id from 1st query>>'

 

-- Place the id of the maintenance plan you want to delete

-- into the below query and delete the entry from subplans table

DELETE FROM msdb.dbo.sysmaintplan_subplans WHERE plan_id = '<<id from 1st query>>'

 

-- Place the id of the maintenance plan you want to delete

-- into the below query to delete the entry from the plans table

DELETE FROM msdb.dbo.sysmaintplan_plans WHERE id = '<<id from 1st query>>'

 

Now you can delete the jobs from Management Studio. 

________________________________________________________________________________
I hope your summer is smooth sailing, but if you need help with SQL server, please contact me. And don't forget to regularly monitor the 11 VitalSigns  used by SQLRx to debug performance bottlenecks.

You can access SQLRx training videos at www.msdev.com, a Microsoft training site!  Check the site periodically to view new training videos.
 
If you have a SQL question you'd like us to answer, and possibly use for the next SQLRx Tip of the Month or msdev video, email it to us!  If you missed any of our previous tips, you can view them here.

For assistance or more information on optimizing your SQL Server Environment, visit us at www.sqlrx.com or email Lori Brown at lorib@isi85.com.


Sincerely,

 

Lori Brown | SQLRx Senior Consultant | Integrated Services, Inc.
4144 N. Central Expwy, Suite 430  |  Dallas, TX  75204
Phone: 214.526.7680 x 113 | lorib@isi85.com 

 

 

Integrated Services, Inc.                                    
2008 winner logo small
Turning Data Into Profit

 

25 Years of Credibility & Trust

 

Join our email list          Check out our events          SQLRx Downloads