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][email protected] )
and run_date=convert(varchar,getdate(),112)
and run_status=0)
begin
set @bd=‘10.158.32.154 计划任务 ‘[email protected]+‘ 执行失败!‘
exec MaganerDB.dbo.[spSendMail] @from=‘[email protected]‘,
@to=‘[email protected];[email protected]‘,
@bcc=‘‘, -- 抄送
@subject=‘自动化任务失败‘,
@[email protected],
@addAttachment=‘‘ -- 附件
end
end
sqlserver 监控自动化作业执行情况
时间: 2024-10-05 08:55:38