0% found this document useful (0 votes)
39 views6 pages

SSRS Report Usage Queries

Uploaded by

fredel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views6 pages

SSRS Report Usage Queries

Uploaded by

fredel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

3/28/24, 11:38 AM SSRS Report Usage Queries - Steve Stedman

SSRS Report Usage Queries


STEVESTEDMAN POSTED ON JANUARY 24, 2016 POSTED IN SSRS 32 COMMENTS TAGGED WITH AVG, DATA
SOURCE, LINKED REPORT, MAX, SELECT, SSRS, STEVE STEDMAN, SUM

This last week I had the opportunity to do some work with SSRS, determining some stats on report
usage. I ended up digging up some queries that I wrote a couple years ago against the
ReportServer database, and thought they would be worthwhile to share, so here they are. These
have been tested against SQL Server 2008, and 2008R2 databases.

I hope these can save you some time if you need to track down details on SSRS report usage.

There is one place where the text DOMAIN_NAME is referenced. That is intended to be replaced
with your current domain.

Find out how many reports executions are in the log, and the oldest TimeStart

1 -- Written by Steve Stedman http://SteveStedman.com


2 SELECT COUNT(*),
3 MIN(ExecutionLog.TimeStart)
4 FROM [ReportServer].[dbo].ExecutionLog(NOLOCK);

Just looking at what is in the log.

1 -- Written by Steve Stedman http://SteveStedman.com


2 SELECT TOP 100 c.Name,
3 c.[Path],
4 l.InstanceName,
5 l.ReportID,
6 l.UserName,
7 l.RequestType,
8 l.Format,
9 l.Parameters,
10 l.TimeStart,
11 l.TimeEnd,
12 l.TimeDataRetrieval,
13 l.TimeProcessing,
14 l.TimeRendering,
15 l.Source,
16 l.Status,
17 l.ByteCount,
https://stevestedman.com/2016/01/ssrs-report-usage-queries/ 1/6
3/28/24, 11:38 AM SSRS Report Usage Queries - Steve Stedman

18 l.[RowCount]
19 FROM [ReportServer].[dbo].[ExecutionLog](NOLOCK) AS l
20 INNER JOIN [ReportServer].[dbo].[Catalog](NOLOCK) AS c ON l.ReportID =
21 WHERE c.Type = 2 -- Only show reports 1=folder, 2=Report, 3=Resource,
22 ORDER BY l.TimeStart DESC;

List the reports with the number of executions and time last run:

1 -- Written by Steve Stedman http://SteveStedman.com


2 SELECT c.Name,
3 c.[Path],
4 COUNT(*) AS TimesRun,
5 MAX(l.TimeStart) AS [LastRun]
6 FROM [ReportServer].[dbo].[ExecutionLog](NOLOCK) AS l
7 INNER JOIN [ReportServer].[dbo].[Catalog](NOLOCK) AS c ON l.ReportID =
8 WHERE c.Type = 2 -- Only show reports 1=folder, 2=Report, 3=Resource,
9 GROUP BY l.ReportId,
10 c.Name,
11 c.[Path];

List the reports with the number of executions and time last run, including datasources.

1 -- Written by Steve Stedman http://SteveStedman.com


2 SELECT c.Name,
3 c.[Path],
4 COUNT(*) AS TimesRun,
5 MAX(l.TimeStart) AS [LastRun],
6 (
7 SELECT SUBSTRING(
8 (
9 SELECT CAST(', ' AS VARCHAR(MAX))+CAST(c1.Name AS VARCHAR(MAX))
10 FROM [ReportServer].[dbo].[Catalog] AS c
11 INNER JOIN [ReportServer].[dbo].[DataSource] AS d ON c.ItemID = d.Item
12 INNER JOIN [ReportServer].[dbo].[Catalog] c1 ON d.Link = c1.ItemID
13 WHERE c.Type = 2
14 AND c.ItemId = l.ReportId
15 FOR XML PATH('')
16 ), 3, 10000000) AS list
17 ) AS DataSources
18 FROM [ReportServer].[dbo].[ExecutionLog](NOLOCK) AS l
19 INNER JOIN [ReportServer].[dbo].[Catalog](NOLOCK) AS c ON l.ReportID =
20 WHERE c.Type = 2 -- Only show reports 1=folder, 2=Report, 3=Resource,
https://stevestedman.com/2016/01/ssrs-report-usage-queries/ 2/6
3/28/24, 11:38 AM SSRS Report Usage Queries - Steve Stedman

21 GROUP BY l.ReportId,
22 c.Name,
23 c.[Path];

List the reports with the number of executions and time last run, including datasources and who
has been using the report.

1 -- Written by Steve Stedman http://SteveStedman.com


2 SELECT c.Name,
3 c.[Path],
4 COUNT(*) AS TimesRun,
5 MAX(l.TimeStart) AS [LastRun],
6 (
7 SELECT SUBSTRING(
8 (
9 SELECT CAST(', ' AS VARCHAR(MAX))+CAST(c1.Name AS VARCHAR(MAX))
10 FROM [ReportServer].[dbo].[Catalog] AS c
11 INNER JOIN [ReportServer].[dbo].[DataSource] AS d ON c.ItemID = d.Item
12 INNER JOIN [ReportServer].[dbo].[Catalog] c1 ON d.Link = c1.ItemID
13 WHERE c.Type = 2
14 AND c.ItemId = l.ReportId
15 FOR XML PATH('')
16 ), 3, 10000000) AS list
17 ) AS DataSources,
18 (
19 SELECT SUBSTRING(
20 (
21 SELECT CAST(', ' AS VARCHAR(MAX))+CAST(REPLACE(t.UserName, 'DOMAIN_NAM
22 FROM
23 (
24 SELECT TOP 100000 l2.UserName+'('+CAST(COUNT(*) AS VARCHAR(100))+')' A
25 FROM [ReportServer].[dbo].[ExecutionLog](NOLOCK) AS l2
26 WHERE l2.ReportID = l.ReportId
27 GROUP BY l2.UserName
28 ORDER BY COUNT(*) DESC
29 ) AS t
30 FOR XML PATH('')
31 ), 3, 10000000)
32 ) AS UsedBy
33 FROM [ReportServer].[dbo].[ExecutionLog](NOLOCK) AS l
34 INNER JOIN [ReportServer].[dbo].[Catalog](NOLOCK) AS c ON l.ReportID =
35 WHERE c.Type = 2 -- Only show reports 1=folder, 2=Report, 3=Resource,
36 GROUP BY l.ReportId,
37 c.Name,
38 c.[Path];

https://stevestedman.com/2016/01/ssrs-report-usage-queries/ 3/6
3/28/24, 11:38 AM SSRS Report Usage Queries - Steve Stedman

Reports that haven’t been run since the last time the log was cleared.

1 -- Written by Steve Stedman http://SteveStedman.com


2 SELECT c.Name,
3 c.[Path]
4 FROM [ReportServer].[dbo].[ExecutionLog](NOLOCK) AS l
5 RIGHT OUTER JOIN [ReportServer].[dbo].[Catalog](NOLOCK) AS c ON l.Repor
6 WHERE c.Type = 2 -- Only show reports 1=folder, 2=Report, 3=Resource, 4
7 AND l.ReportID IS NULL;

1 -- Reports by count that have been run in the last 24 hours


2 -- Written by Steve Stedman http://SteveStedman.com
3 SELECT c.Name,
4 c.[Path],
5 COUNT(*) AS TimesRun,
6 MAX(l.TimeStart) AS [LastRun]
7 FROM [ReportServer].[dbo].[ExecutionLog](NOLOCK) AS l
8 INNER JOIN [ReportServer].[dbo].[Catalog](NOLOCK) AS c ON l.ReportID =
9 WHERE c.Type = 2 -- Only show reports 1=folder, 2=Report, 3=Resource,
10 AND l.TimeStart > GETDATE() - 1
11 GROUP BY l.ReportId,
12 c.Name,
13 c.[Path];

https://stevestedman.com/2016/01/ssrs-report-usage-queries/ 4/6
3/28/24, 11:38 AM SSRS Report Usage Queries - Steve Stedman

1 -- Reports by count that have been run in the last 7 days


2 -- Written by Steve Stedman http://SteveStedman.com
3 SELECT c.Name,
4 c.[Path],
5 COUNT(*) AS TimesRun,
6 MAX(l.TimeStart) AS [LastRun]
7 FROM [ReportServer].[dbo].[ExecutionLog](NOLOCK) AS l
8 INNER JOIN [ReportServer].[dbo].[Catalog](NOLOCK) AS c ON l.ReportID =
9 WHERE c.Type = 2 -- Only show reports 1=folder, 2=Report, 3=Resource,
10 AND l.TimeStart > GETDATE() - 7
11 GROUP BY l.ReportId,
12 c.Name,
13 c.[Path];

Report usage by user

1 -- Written by Steve Stedman http://SteveStedman.com


2 SELECT l.UserName,
3 COUNT(*) AS TimesRun,
4 MAX(l.TimeStart) AS [LastReportRun]
5 FROM [ReportServer].[dbo].[ExecutionLog](NOLOCK) AS l
6 INNER JOIN [ReportServer].[dbo].[Catalog](NOLOCK) AS c ON l.ReportID =
7 GROUP BY l.UserName;
8
9 -- Reports Datasource
10 -- Written by Steve Stedman http://SteveStedman.com
11 SELECT c.name,
12 c1.Name datasource,
13 c.ItemId
14 FROM [ReportServer].[dbo].[Catalog] AS c
15 INNER JOIN [ReportServer].[dbo].[DataSource] AS d ON c.ItemID = d.Item
16 INNER JOIN [ReportServer].[dbo].[Catalog] c1 ON d.Link = c1.ItemID
17 WHERE c.Type = 2;

Long Running Reports by average execution time

1 -- Written by Steve Stedman http://SteveStedman.com


2 SELECT TOP 100 c.Name,
https://stevestedman.com/2016/01/ssrs-report-usage-queries/ 5/6
3/28/24, 11:38 AM SSRS Report Usage Queries - Steve Stedman

3 c.[Path],
4 AVG(l.TimeDataRetrieval + l.TimeProcessing + l.TimeRendering) / 1000.0
5 SUM(l.TimeDataRetrieval + l.TimeProcessing + l.TimeRendering) / 1000.0
6 SUM(l.TimeDataRetrieval + l.TimeProcessing + l.TimeRendering) / 1000.0
7 COUNT(*) TimesRun
8 FROM [ReportServer].[dbo].[ExecutionLog](NOLOCK) AS l
9 INNER JOIN [ReportServer].[dbo].[Catalog](NOLOCK) AS c ON l.ReportID =
10 WHERE c.Type = 2 -- Only show reports 1=folder, 2=Report, 3=Resource,
11 GROUP BY c.Name,
12 c.[Path],
13 l.InstanceName,
14 l.ReportID
15 HAVING AVG(l.TimeDataRetrieval + l.TimeProcessing + l.TimeRendering) /
16 ORDER BY AVG(l.TimeDataRetrieval + l.TimeProcessing + l.TimeRendering)
17
18 -- List the reports with the last time run
19 -- Written by Steve Stedman http://SteveStedman.com
20 SELECT c.Name,
21 c.[Path],
22 MAX(l.TimeStart) AS [LastRun]
23 FROM [ReportServer].[dbo].[ExecutionLog] AS l WITH (NOLOCK)
24 INNER JOIN [ReportServer].[dbo].[Catalog] AS c WITH (NOLOCK) ON l.Repo
25 WHERE c.Type = 2 -- Only show reports 1=folder, 2=Report, 3=Resource,
26 GROUP BY l.ReportId,
27 c.Name,
28 c.[Path]
29 ORDER BY [LastRun] DESC;

https://stevestedman.com/2016/01/ssrs-report-usage-queries/ 6/6

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy