-- Stored Procedure: dbo.sp_check_job_status -- Bill Wunder use admin GO SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_check_job_status]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[sp_check_job_status] GO CREATE PROCEDURE "sp_check_job_status" as set nocount on select h.run_date as "Run Date", h.run_time as "Run Time", cast(j.name as varchar(30)) as "Job Name", cast(h.step_name as varchar(30)) as "Step Name" , h.message as "Message" from msdb.dbo.sysjobhistory h inner join msdb.dbo.sysjobs j on h.job_id = j.job_id where message not like ('% succeeded%') and message not like ('%did not generate any output%') and message not like ('%SQLMaint%') and step_name not like ('%(Job outcome)%') and h.run_date > datepart(yyyy, current_timestamp - 7) * 10000 + datepart(mm, current_timestamp - 7) * 100 + datepart(dd, current_timestamp - 7) order by h.run_date desc GO SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO