Home All Groups Group Topic Archive Search About

SQL2k5 maint subplan wont delete completely

Author
8 May 2007 4:49 PM
Steve M
I created a maint plan in SQL2k5. I then needed to duplicate the plan, so I
scripted the jobs, changed the names, and ran the script. I then needed to
delete some of the maint plans. I deleted the plans, and the jobs didn't
delete. Now I try to delete the subplan jobs, and I get a:

Msg 547, Level 16, State 0, Procedure sp_delete_job, Line 178
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 statement has been terminated.

error.

ok, this is a typical problem with using f key constraints - you can get
yourself into never-never land, where you can't delete your orphaned recs
(which shouldn't have been allowed to exist, but nevertheless do). In the
past I've handeled this by dropping the fk constraints, making the data mods,
and then re-applying the fk constraints. Here I'm reluctant to because it's
in msdb and I don't even have a schema diagram of msdb.

Can someone give me a suggestion about how I might clean up this SQL2k5 mess ?

Steve

p.s. This is the reason I recommend never using fk constraints on a freshly
developed schema. You manage data integrity via procs.

AddThis Social Bookmark Button