Monday, 9 April 2018

How to get SSRS Report Subscription, Share Schedule, Last run date & Status

These are the tables that are relevant for pulling out the subscription information:
  • dbo.Catalog - Information about the deployed reports
  • dbo.ReportSchedule - Information relating reports to schedules and schedules
  • dbo.Subscriptions - Information about the subscriptions
  • dbo.Schedule - Information about the schedules
The SQL below pulls out schedule interval information for all reports. It doesn't calculate the next run dates but by figuring out the interval that the schedule is supposed to run on you can write another query to generate the actual dates.
This SQL was originally written for a report that just displays a string describing the interval so the final output is probably not what you're after. It should give you a good starting point though since it does figure out all of the interval details.

USE REPORTSERVER
GO
SELECT C.NAME AS Report_Name ,S.Description AS Subscription_Name ,SCH.NAME Share_Schedule,S.LastRunTime Subscription_LastRunTime,S.LastStatus 
FROM [dbo].[Schedule] SCH 
INNER JOIN [dbo].[ReportSchedule] RS ON RS.ScheduleID=SCH.ScheduleID
LEFT JOIN [dbo].[Subscriptions] S ON S.SubscriptionID=RS.SubscriptionID
LEFT JOIN [Catalog] C ON C.ItemID=RS.REportID