今天删除SQLServer维护计划的时候出现下面的错误:
The DELETE statement conflicted with the REFERENCE constraint "FK_subplan_job_id". The conflict occurred in database "msdb", table "dbo.sysmaintplan_subplans". (Microsft SQL Server, Error:547)
解决办法:
Use MSDB
go
delete from sysmaintplan_subplanswherejob_idin
( select job_idfromsysjobswhere namelike'%MaintenancePlan.Subplan_1%')
执行成功后在Management studio中可以正常删除维护计划Job。
如果上面的语句无法成功,提示“tablesysmaintplan_log”,可以先执行下面的语句然后在删除sysmaintplan_subplans记录。
deletesysmaintplan_log
fromsysmaintplan_subplans as subplans INNER JOIN
sysjobs_viewas syjobsonsubplans.job_id=syjobs.job_idINNERJOIN
sysmaintplan_log onsubplans.subplan_id=sysmaintplan_log.subplan_id
where (syjobs.name= @jobName);
本文转自 lzf328 51CTO博客,原文链接:http://blog.51cto.com/lzf328/968394