I have some reports that are configured for email delivery in reporting services. Last night we experienced some network outtages and reporting services was unable to connec
Below the script will send notification too..
--Below script can be used to send the Notification everyday morning to your email id.
DECLARE @tableHTML NVARCHAR(MAX) ;
DECLARE @COUNT INT
DECLARE @FileCreationDate varchar(20)
SET @COUNT = (SELECT count(*)
FROM ReportServer.dbo.Subscriptions s
WHERE (s.LastStatus LIKE 'Failure%' OR s.LastStatus LIKE 'Error%')
AND s.LastRunTime > DATEADD(D, -1, GETDATE()))
IF @COUNT >0
BEGIN
SET @tableHTML =
N'SSRS Report Subscription Failures
' +
N'' +
N' ScheduleID Name ' +
N'Description DeliveryExtension LastStatus ' + N'LastRunTime ' +
N'Path ' +
CAST ( ( select
TD = sc.ScheduleID , '',
TD = c.Name , '',
TD = sb.[Description] , '',
TD = sb.DeliveryExtension , '',
TD = sb.LastStatus , '',
TD = sb.LastRunTime , '',
TD = c.Path
FROM ReportServer.dbo.ReportSchedule rs
INNER JOIN ReportServer.dbo.Schedule sc ON rs.ScheduleID = sc.ScheduleID
INNER JOIN ReportServer.dbo.Subscriptions sb ON rs.SubscriptionID = sb.SubscriptionID
INNER JOIN ReportServer.dbo.[Catalog] c ON rs.ReportID = c.ItemID AND sb.Report_OID = c.ItemID
WHERE (sb.LastStatus LIKE 'Failure%' OR sb.LastStatus LIKE 'Error%')
AND sb.LastRunTime > DATEADD(D, -1, GETDATE())
FOR XML PATH('tr'), TYPE
) AS NVARCHAR(MAX) ) +
N'
' ;
EXEC msdb.dbo.sp_send_dbmail @recipients='Mailid',
@subject = 'SSRS Subscription Failures',
@body = @tableHTML,
@body_format = 'HTML' ;
END