加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

sqlserver 监控自动化作业执行情况

发布时间:2020-12-12 13:13:57 所属栏目:MsSql教程 来源:网络整理
导读:ALTER procedure [dbo].[monitorJob] @name varchar(100) as begin declare @bd varchar(100) ; if exists( select * from ?msdb.dbo.sysjobhistory? where job_id in (select job_id from msdb.dbo.sysjobs where [name]=@name ) and run_date=convert(varc


ALTER procedure [dbo].[monitorJob]

@name varchar(100)

as

begin


declare @bd varchar(100) ;


if exists(

select * from ?msdb.dbo.sysjobhistory?

where job_id in (select job_id from msdb.dbo.sysjobs where [name]=@name )

and run_date=convert(varchar,getdate(),112)?

and run_status=0)

begin


set @bd='10.158.32.154 计划任务 '+@name+' 执行失败!'


exec MaganerDB.dbo.[spSendMail] ?@from='dwchaoyue@163.com',?

? ? ? ? ? ? ? ? ? ?@to='v.dengwang@snda.com;lidenggao@snda.com',

? ? ? ? ? ? ? ? ? ?@bcc='',?-- 抄送

? ? ? ? ? ? ? ? ? ?@subject='自动化任务失败',?

? ? ? ? ? ? ? ? ? ?@htmlBody=@bd,

? ? ? ? ? ? ? ? ? ?@addAttachment='' -- 附件


end?


end?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读