之前碰到过自己新建的SqlServer维护计划想要删除时删不掉的问题,搜索了半天也没找到解决方法,几乎没有相应的帖子。最后在国外的网站上找到了方法,发现很好用,在这里和大家分享一下免得以后不好找。
代码
但是这个方法不能确定是否已将所有的系统表中的关于这个维护计划的记录都删除了,希望大家有知道的能给点意见,以上的方法自己使用过很多次了是可以的。
![](https://i-blog.csdnimg.cn/blog_migrate/cdec0645add3fc3c328197dda5c76203.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
1
. 先执行下面的语句将维护计划的ID查出。
select * from sysmaintplan_plans
2 . 将查出的ID填入到下面几句话中的 '' 中,并执行。
delete from sysmaintplan_log where plan_id = ''
delete from sysmaintplan_subplans where plan_id = ''
delete from sysmaintplan_plans where id = ''
3 . 在Sql Agent中删除相应的Job(维护计划会自动建立相应的Job).
select * from sysmaintplan_plans
2 . 将查出的ID填入到下面几句话中的 '' 中,并执行。
delete from sysmaintplan_log where plan_id = ''
delete from sysmaintplan_subplans where plan_id = ''
delete from sysmaintplan_plans where id = ''
3 . 在Sql Agent中删除相应的Job(维护计划会自动建立相应的Job).
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16436858/viewspace-622142/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/16436858/viewspace-622142/