无法删除SQLSERVER代理任务时可用如下语句试验下
use [msdb] declare @job_name varchar(100) set @job_name = N'jobname' --注:job_name为维护计划对应的job name --删除在计划里面的日志 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