Skip to content

Instantly share code, notes, and snippets.

@taddison
Last active August 23, 2017 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taddison/b1a96ece28b40b32ecd916dfade0f496 to your computer and use it in GitHub Desktop.
Save taddison/b1a96ece28b40b32ecd916dfade0f496 to your computer and use it in GitHub Desktop.
ReportServer - failed subscriptions
use ReportServer
go
drop table if exists #failedSubs
select c.ItemID
,u.UserName as SubscriptionOwner
,s.Description as SubscriptionDescription
,s.LastStatus
,s.SubscriptionID
,c.Name as ReportName
,c.Path
,lastExec.TimeStart
,lastExec.TimeEnd
,lastExec.TimeDataRetrieval / 1000 as DataRetrievalSeconds
,lastExec.TimeProcessing as ProcessingTimeMs
,lastExec.ByteCount
,lastExec.[RowCount]
,lastexec.Status
into #failedSubs
from dbo.Subscriptions as s
join dbo.Users as u
on u.UserID = s.OwnerID
join dbo.Catalog as c
on c.ItemID = s.Report_OID
outer apply (
select top 1 *
from dbo.ExecutionLogStorage as els
where els.ReportID = c.ItemID
order by els.TimeStart desc
) as lastExec
where s.LastStatus like 'Failure sending%'
or s.LastStatus like 'Error%'
order by s.LastStatus asc
select *
from #failedSubs as fs
cross apply (
select count(*) as TotalExecutions
,sum(case when els.Status <> N'rsSuccess' then 1 else 0 end) as Failures
from dbo.ExecutionLogStorage as els
where els.ReportID = fs.ItemID
and els.TimeStart >= getutcdate() - 7
) as weekStats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment