I found the below scripts online:
SELECT
CASE [sJOB].[enabled]
WHEN 0 THEN 'Disabled'
WHEN 1 THEN 'Enabled'
END AS [Enabled]
,[sJob].[description] AS [JobDesc]
,[sJOB].[job_id] AS [JobID]
, [sJOB].[name] AS [JobName]
,[sSch].next_run_Date as [Next Schedule to Run]
, [sJSTP].[step_uid] AS [StepID]
, [sJSTP].[step_id] AS [StepNo]
, [sJSTP].[step_name] AS [StepName]
, CASE [sJSTP].[last_run_outcome]
WHEN 0 THEN 'Failed'
WHEN 1 THEN 'Succeeded'
WHEN 2 THEN 'Retry'
WHEN 3 THEN 'Canceled'
WHEN 5 THEN 'Unknown'
END AS [LastRunStatus]
,[sJSTP].[last_run_outcome]
, STUFF(
STUFF(RIGHT('000000' + CAST([sJSTP].[last_run_duration] AS VARCHAR(6)), 6)
, 3, 0, ':')
, 6, 0, ':')
AS [LastRunDuration (HH:MM:SS)]
, [sJSTP].[last_run_retries] AS [LastRunRetryAttempts]
, CASE [sJSTP].[last_run_date]
WHEN 0 THEN NULL
ELSE
CAST(
CAST([sJSTP].[last_run_date] AS CHAR(8))
+ ' '
+ STUFF(
STUFF(RIGHT('000000' + CAST([sJSTP].[last_run_time] AS VARCHAR(6)), 6)
, 3, 0, ':')
, 6, 0, ':')
AS DATETIME)
END AS [LastRunDateTime]
FROM
[msdb].[dbo].[sysjobsteps] AS [sJSTP]
INNER JOIN [msdb].[dbo].[sysjobs] AS [sJOB]
ON [sJSTP].[job_id] = [sJOB].[job_id]
INNER JOIN [msdb].[dbo].[sysjobschedules] AS [sSch]
ON [sJOB].[job_id] = [sSch].[job_id]
WHERE last_run_outcome = 0
AND [sJOB].enabled = 1
AND [sSch].next_run_Date <> 0
ORDER BY [JobName], [StepNo]
SECOND QUERY:
SELECT C.Name, S.LastRunTime, S.LastStatus, S.Description,
C.Path
FROM [ReportS].[dbo].[subscriptions] AS S
LEFT OUTER JOIN [ReportS].[dbo].[Catalog] AS C
ON C.ItemID = S.Report_OID
WHERE LEFT (S.LastStatus, 12) != 'Mail sent to'
AND LEFT (S.LastStatus, 12) != 'New Subscrip'
AND S.LastStatus LIKE '%Fail%'
When I run this, the I get an error for the first step of the subscription job that inserts a record into the Reports server's Event table.
But, when I run the second query with the actual subscriptions and catalog tables on my reports server.
I need to be sure I'm understand why this happens - is it because the Subscriptions and catalog tables only log failures when the actual subscription notification is not sent and the script I found online logs actual failures with the individual job steps?
What I have tried:
I have search the MSDN site and MSDN blogs, google search