简体   繁体   中英

Find SSRS subscriptions that never ran successful in the past 30 days?

I'm trying to write a SQL select statement to find the SSRS subscriptions that never successfully ran in the past 30 days so I can disable those subscriptions.

Anyone got an idea how to do that? Since execution logs create unique records every time when a job runs I was trying to group them by the report path but got stuck there. Can someone help me?

My thoughts was like:

SELECT ItemPath
FROM [ReportServer].dbo.ExecutionLog3 EX
GROUP BY ItemPath, Status, TimeEnd
HAVING Ex.TimeEnd >= DATEADD(day, -30, GETDATE())
   AND Status != 'rsSuccess'

Here's an algorithm to help you:

With
Subscriptions As
(
    Select SubscriptionId, SubscriptionName
    From dbo.TableOfSubscriptions
)
, Executions As
(
    Select SubscriptionId, ExecutionStatus, Count (*) NumExecutions
    From dbo.TableOfExecutions
    Group By SubscriptionId, ExecutionStatus
)
, SubscriptionsExecutions As
(
    Select 
        SubscriptionId, SubscriptionName
        , IsNull((Select Sum (NumExecutions) From Executions Where ExeuctionStatus = 'Failed'), 0) ExecutionFailed
        , IsNull((Select Sum (NumExecutions) From Executions Where ExeuctionStatus = 'Success'), 0) ExecutionSuccessful
    From Subscriptions
)
Select *
From SubscriptionsExecutions
Where ExecutionSuccessful = 0
and ExecutionFailed <> 0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM