USE [msdb]
DECLARE @job_name VARCHAR(100)
SET @job_name = N'syspolicy_purge_history'
--注:jobname为维护计划对应的jobname
--删除在计划里面的日志
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
sysjobschedules FROM sysjobs_vIEw v
INNER JOIN sysjobschedules o ON v.job_ID=o.job_ID
WHERE
v.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)
--删除作业
DELETE FROM msdb.dbo.sysjobs_vIEw WHERE name = @job_name
总结以上是内存溢出为你收集整理的解决 SQLSERVER 2008 无法删除作业全部内容,希望文章能够帮你解决解决 SQLSERVER 2008 无法删除作业所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)