Uncategorized

List of all reports with last execution statistics

Query to extract the list of all reports from Reporting Services with the last execution details. Tested with SSRS 2019.

SELECT 
	[c].[ItemID] [ReportID], [c].[Path] [ReportPath], [c].[Name] [ReportName], [c].[Description],
	'http://report_browser_urlp-app.ud4d.com/Reports/report' + REPLACE([c].[Path] , ' ', '%20') [ReportLink],
	[c].[Property], [c].[Hidden] [IsHidden], 
	[uc].[UserName] [CreatedBy], [c].[CreationDate], 
	[um].[UserName] [ModifiedBy], [c].[ModifiedDate],
	[c].[MimeType],	[c].[SnapshotLimit], 
	[c].[ExecutionFlag], [c].[ExecutionTime],[c].[SubType],	[c].[ContentSize],
	[me].[UserName] [LastExecUser],
	[me].[Parameters] [LastExecParameters],
	[me].[TimeStart] [LastExecTimeStart],
	[me].[TimeEnd] [LastExecTimeEnd],
	[me].[TimeDataRetrieval] [LastExecTimeDataRetrieval],
	[me].[TimeProcessing] [LastExecTimeProcessing],
	[me].[TimeRendering] [LastExecTimeRendering],
	[me].[TotalDuration] [LastExecTotalDuration]
FROM [ReportServer].[dbo].[Catalog] [c] 
	LEFT JOIN [ReportServer].[dbo].[Users] [uc] ON [c].[CreatedByID] = [uc].[UserID]
	LEFT JOIN [ReportServer].[dbo].[Users] [um] ON [c].[ModifiedByID] = [um].[UserID]
	LEFT JOIN (SELECT [el].[ReportID], [UserName], [el].[Parameters], [el].[TimeStart], [el].[TimeEnd],
					  [el].[TimeDataRetrieval], [el].[TimeProcessing], [el].[TimeRendering],
					  DATEDIFF(ms, [el].[TimeStart], [el].[TimeEnd]) [TotalDuration]
			   FROM [ReportServer].[dbo].[ExecutionLogStorage] [el]
			   WHERE [el].[LogEntryId] IN (	select MAX([el].[LogEntryId]) [LogEntryID]
											FROM [ReportServer].[dbo].[ExecutionLogStorage] [el]
												INNER JOIN [ReportServer].[dbo].[Catalog] [c] ON [c].[ItemID] = [el].[ReportID]
											GROUP BY [el].[ReportID])
	) [me] ON [me].[ReportID] = [c].[ItemID]
WHERE [c].[Type] = 2