有一个计划在SQL 2005中,删除时提示错误。
按照网上的做法首先
select * from sysmaintplan_plans
但在这个表里没有相关JOB的信息。也就无法再
作如下操作了
delete from sysmaintplan_log where plan_id = '' 织梦好,好织梦 delete from sysmaintplan_subplans where plan_id = '' dedecms.com delete from sysmaintplan_plans where id = ''
不知道大家还有没有更好的方法。
按照网上的做法首先
select * from sysmaintplan_plans
但在这个表里没有相关JOB的信息。也就无法再
作如下操作了
delete from sysmaintplan_log where plan_id = '' 织梦好,好织梦 delete from sysmaintplan_subplans where plan_id = '' dedecms.com delete from sysmaintplan_plans where id = ''
不知道大家还有没有更好的方法。
啥错?
msdb.dbo.sp_delete_job
the DELETE statement conflicted with the REFERENCE constraint "FK_subplan_job_id". The conflict occurred in database "msdb",table "dbo.sysmainplan_subplans",column "job_id". The statement has been terminated(Microsoft SQL Server, Error:547)
先删 sysmaintplan_subplans 试试delete from sysmaintplan_subplans
where subplan_name = 'SubplanName'
是的,首先MAINTANANCE 和 AGNENT JOB 之间是需要链接的,这也就是在系统表里面的建值,所以目前的问题是,之间的链接断了,你删除那一方,都不会关联对方,所以目前的问题你只能从系统表里面做删除了
删除 对于 Job“temp1.Subplan_1”失败。 (Microsoft.SqlServer.Smo)
DELETE 语句与 REFERENCE 约束"FK_subplan_job_id"冲突。该冲突发生于数据库"msdb",表"dbo.sysmaintplan_subplans", column 'job_id'。
语句已终止。 (Microsoft SQL Server,错误: 547)与维护计划有关的有三张表:
1.sysmaintplan_log:在维护计划运行后,会在此表中进行记录;
2.sysmaintplan_subplans:记录维护计划的子计划信息
3.sysjobs_view:相关的作业信息这三张表有着PK和FK的关联关系,在删除作业时,就容易因为发生FK的冲突而导致失败。具体的处理方法如下:
USE [msdb]
declare @job_name varchar(100)
set @job_name = N'test.Subplan_1'--删除在计划里面的日志delete sysmaintplan_log
FROM sysmaintplan_subplans AS subplans INNER JOIN
sysjobs_view AS syjobs ON subplans.job_id = syjobs.job_id INNER JOIN
sysmaintplan_log ON subplans.subplan_id = sysmaintplan_log.subplan_id
WHERE (syjobs.name = @job_name)--删除子计划delete sysmaintplan_subplans
FROM sysmaintplan_subplans AS subplans INNER JOIN
sysjobs_view AS syjobs ON subplans.job_id = syjobs.job_id
WHERE (syjobs.name = @job_name)--删除作业,也可以直接在Mangement Studio里面直接删除delete
from msdb.dbo.sysjobs_view where name = @job_namehttp://hi.baidu.com/anydb/blog/item/be037e3a297e362fb8998f0c.html