Tried to delete a maintenance plan

  • I was able to delete the Maintenance plan, but the subplan job remains.   When I try to delete it I get the following error:
    The delete statement conflicted with the REFERENCE constraint FK_subplan_Job_id.  The conflict occurred
    in database msdb table dbo.sysmaintplan_subplan column job_id.  The statement has been terminated.

    Help please.

    When the snows fall and the white winds blow,The lone wolf dies but the pack survives.

    Once you've accepted your flaws, no one can use them against you.

  • fizzleme - Thursday, January 26, 2017 4:57 PM

    I was able to delete the Maintenance plan, but the subplan job remains.   When I try to delete it I get the following error:
    The delete statement conflicted with the REFERENCE constraint FK_subplan_Job_id.  The conflict occurred
    in database msdb table dbo.sysmaintplan_subplan column job_id.  The statement has been terminated.

    Help please.

    Pretty sure this is some bug with Maintenance plans that they didn't fix. There was a bug report/connect item on this and the subplan doesn't really delete. So query sysmaintplan_subplans and see if the subplan is still in there. You should join on sysjobs to be sure its the subplan/job combination that you are seeing, something like:
    SELECT j.name as JobName, s.*
    FROM msdb.dbo.sysmaintplan_subplans s
    INNER JOIN msdb.dbo.sysjobs j
    ON s.job_id = j.job_id

    If you are finding the subplan there, which you probably are, delete it from sysmaintplan_subplans. Get the subplan ID using the above query and then do something like:
    DELETE msdb.dbo.sysmaintplan_subplans
    WHERE subplan_id = <YourSubplanID>

    Sue

  • Sue_H - Thursday, January 26, 2017 5:33 PM

    fizzleme - Thursday, January 26, 2017 4:57 PM

    I was able to delete the Maintenance plan, but the subplan job remains.   When I try to delete it I get the following error:
    The delete statement conflicted with the REFERENCE constraint FK_subplan_Job_id.  The conflict occurred
    in database msdb table dbo.sysmaintplan_subplan column job_id.  The statement has been terminated.

    Help please.

    Pretty sure this is some bug with Maintenance plans that they didn't fix. There was a bug report/connect item on this and the subplan doesn't really delete. So query sysmaintplan_subplans and see if the subplan is still in there. You should join on sysjobs to be sure its the subplan/job combination that you are seeing, something like:
    SELECT j.name as JobName, s.*
    FROM msdb.dbo.sysmaintplan_subplans s
    INNER JOIN msdb.dbo.sysjobs j
    ON s.job_id = j.job_id

    If you are finding the subplan there, which you probably are, delete it from sysmaintplan_subplans. Get the subplan ID using the above query and then do something like:
    DELETE msdb.dbo.sysmaintplan_subplans
    WHERE subplan_id = <YourSubplanID>

    Sue

    After running the delete statement, I was able to delete the job.   Congrats and Thanks.

    When the snows fall and the white winds blow,The lone wolf dies but the pack survives.

    Once you've accepted your flaws, no one can use them against you.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply