今天删除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);
SQLServer维护计划删除错误解决
本文介绍了解决在删除SQLServer维护计划时遇到的REFERENCE约束冲突错误的具体步骤。通过执行特定的SQL语句来清除相关联记录,使得能够顺利删除维护计划。
4449

被折叠的 条评论
为什么被折叠?



