SSRS execution log query

Sometimes I get a request for information about SQL Server Reporting Services report execution frequency. Managers will want to know who is running reports and how often. I want to know what reports are not being used so I can make a case to delete them. I wrote a query to tell you the count the report has executed along with the oldest and most recent execution dates .Run this in your report server database.

SELECT  c.[Path] ,
        c.Name ,
        COUNT(l.ReportID) AS '# of logged executions' ,
        MIN(l.TimeStart) AS 'min logged date' ,
        MAX(l.TimeStart) AS 'max logged date'
FROM    dbo.Catalog c
        LEFT JOIN dbo.ExecutionLog l ON c.ItemID = l.ReportID
GROUP BY c.[Path] ,
        c.Name ,
        c.ItemID
--HAVING COUNT(l.ReportID) = 0 -- shows reports without execution history
ORDER BY c.[Path];
--ORDER BY c.name
--ORDER BY COUNT(l.ReportID) desc

Here I did an additional grouping to break down the count to subscription or interactive  executions.

SELECT  c.[Path] ,
        c.Name ,
        COUNT(l.ReportID) AS '# of logged executions' ,
        MIN(l.TimeStart) AS 'min logged date' ,
        MAX(l.TimeStart) AS 'max logged date' ,
        CASE WHEN l.RequestType = 0 THEN 'Interactive'
             WHEN l.RequestType = 1 THEN 'Subscription'
             WHEN l.RequestType = 2 THEN 'Refresh Cache'
             ELSE NULL
        END RequestType
FROM    dbo.Catalog c
        LEFT JOIN dbo.ExecutionLog l ON c.ItemID = l.ReportID
GROUP BY c.[Path] ,
        c.Name ,
        c.ItemID ,
        CASE WHEN l.RequestType = 0 THEN 'Interactive'
             WHEN l.RequestType = 1 THEN 'Subscription'
             WHEN l.RequestType = 2 THEN 'Refresh Cache'
             ELSE NULL
        END
--ORDER BY c.[Path]
--ORDER BY c.name
ORDER BY COUNT(l.ReportID) DESC;

 

 

Leave a comment