Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSRS Subscriptions - How to view ALL report recipients

I've written an SSRS report to help me keep track of SSRS subscriptions. I've repurposed a script that will use Reportserver.dbo.Subscriptions.LastStatus to view email recipients, however, it will only list the first 520 characters of LastStatus. Because some of our distribution lists are quite large, some of the names that my script searches for are not being found (even though they are part of the distribution). Below is the script that I am using:

SELECT Reportname = c.Name 
  ,FileLocation = c.Path
  ,SubscriptionDesc=su.Description 
  ,Subscriptiontype=su.EventType 
  ,su.LastStatus 
  ,su.LastRunTime 
  ,Schedulename=sch.Name 
  ,ScheduleType = sch.EventType 
  ,ScheduleFrequency = 
   CASE sch.RecurrenceType 
   WHEN 1 THEN 'Once' 
   WHEN 2 THEN 'Hourly' 
   WHEN 4 THEN 'Daily/Weekly' 
   WHEN 5 THEN 'Monthly' 
   END 
  ,su.Parameters 
  FROM Reportserver.dbo.Subscriptions su 
  JOIN Reportserver.dbo.Catalog c 
    ON su.Report_OID = c.ItemID 
  JOIN Reportserver.dbo.ReportSchedule rsc 
    ON rsc.ReportID = c.ItemID 
   AND rsc.SubscriptionID = su.SubscriptionID 
  JOIN Reportserver.dbo.Schedule Sch 
    ON rsc.ScheduleID = sch.ScheduleID 
WHERE  LastStatus like @Email
ORDER BY LastRunTime DESC

Any code that I have found online uses the LastStatus column to display this data. If anyone has any suggestions as to a more complete way for me to list all of the members of the report distribution list, I would appreciate it.

like image 625
Wendy Avatar asked Sep 23 '13 13:09

Wendy


People also ask

How do I find my SSRS subscriptions?

Browse the web portal of a report server (SSRS Native Mode). In the web portal, select My Subscriptions on the toolbar and navigate to the subscription you want to modify or delete.

How do I manage my SSRS subscriptions?

Please navigate yourself to the Subscriptions tab and select the New Subscription option in SSRS. Once you choose the option, the report manager will navigate to the following page. Subscriptions in SSRS supports two types of Delivery options: Windows File Share, and Email.

What are the two methods of delivery for report subscription?

We can deliver the reports in the following ways using SSRS: Email delivery: We can add the email address of the individual recipients as well as user groups for delivering reports in the user's mailbox. File Share delivery: You can export the reports using a subscription and place it on a shared directory.

How many types of subscriptions are there in SSRS?

SSRS allows you to create two types of subscriptions, i.e., standard subscriptions, and data-driven subscriptions.


2 Answers

Below is SQL to query for the full text of the subscription parameters. I think this will work with extremely long address lists, but I don't have a test server with long address lists available right now.

If using this in production, I'd probably throw in a couple of WITH ( NOLOCK )'s and wouldn't expect support from MS on problems.

   ;
   WITH subscriptionXmL
          AS (
               SELECT
                SubscriptionID ,
                OwnerID ,
                Report_OID ,
                Locale ,
                InactiveFlags ,
                ExtensionSettings ,
                CONVERT(XML, ExtensionSettings) AS ExtensionSettingsXML ,
                ModifiedByID ,
                ModifiedDate ,
                Description ,
                LastStatus ,
                EventType ,
                MatchData ,
                LastRunTime ,
                Parameters ,
                DeliveryExtension ,
                Version
               FROM
                ReportServer.dbo.Subscriptions
             ),
                 -- Get the settings as pairs
        SettingsCTE
          AS (
               SELECT
                SubscriptionID ,
                ExtensionSettings ,
    -- include other fields if you need them.
                ISNULL(Settings.value('(./*:Name/text())[1]', 'nvarchar(1024)'),
                       'Value') AS SettingName ,
                Settings.value('(./*:Value/text())[1]', 'nvarchar(max)') AS SettingValue
               FROM
                subscriptionXmL
                CROSS APPLY subscriptionXmL.ExtensionSettingsXML.nodes('//*:ParameterValue') Queries ( Settings )
             )
    SELECT
        *
    FROM
        SettingsCTE
    WHERE
        settingName IN ( 'TO', 'CC', 'BCC' )
like image 106
Jamie F Avatar answered Oct 23 '22 05:10

Jamie F


I also found this query from SQL Server MSDN Social; Original Query Author MSDN Profile: Sandip Shinde

SELECT
c.Name AS ReportName,
'Next Run Date' = CASE next_run_date
WHEN 0 THEN null
ELSE
substring(convert(varchar(15),next_run_date),1,4) + '/' +
substring(convert(varchar(15),next_run_date),5,2) + '/' +
substring(convert(varchar(15),next_run_date),7,2)
END,
'Next Run Time' = isnull(CASE len(next_run_time)
WHEN 3 THEN cast('00:0'
+ Left(right(next_run_time,3),1)
+':' + right(next_run_time,2) as char (8))
WHEN 4 THEN cast('00:'
+ Left(right(next_run_time,4),2)
+':' + right(next_run_time,2) as char (8))
WHEN 5 THEN cast('0' + Left(right(next_run_time,5),1)
+':' + Left(right(next_run_time,4),2)
+':' + right(next_run_time,2) as char (8))
WHEN 6 THEN cast(Left(right(next_run_time,6),2)
+':' + Left(right(next_run_time,4),2)
+':' + right(next_run_time,2) as char (8))
END,'NA'),
Convert(XML,[ExtensionSettings]).value('(//ParameterValue/Value[../Name="TO"])[1]','nvarchar(50)') as [To]
,Convert(XML,[ExtensionSettings]).value('(//ParameterValue/Value[../Name="CC"])[1]','nvarchar(50)') as [CC]
,Convert(XML,[ExtensionSettings]).value('(//ParameterValue/Value[../Name="RenderFormat"])[1]','nvarchar(50)') as [Render Format]
,Convert(XML,[ExtensionSettings]).value('(//ParameterValue/Value[../Name="Subject"])[1]','nvarchar(50)') as [Subject]
---Example report parameters: StartDateMacro, EndDateMacro & Currency.
,Convert(XML,[Parameters]).value('(//ParameterValue/Value[../Name="StartDateMacro"])[1]','nvarchar(50)') as [Start Date]
,Convert(XML,[Parameters]).value('(//ParameterValue/Value[../Name="EndDateMacro"])[1]','nvarchar(50)') as [End Date]
,Convert(XML,[Parameters]).value('(//ParameterValue/Value[../Name="Currency"])[1]','nvarchar(50)') as [Currency]
,[LastStatus]
,[EventType]
,[LastRunTime]
,[DeliveryExtension]
,[Version]
FROM 
 dbo.[Catalog] c
INNER JOIN dbo.[Subscriptions] S ON c.ItemID = S.Report_OID
INNER JOIN dbo.ReportSchedule R ON S.SubscriptionID = R.SubscriptionID
INNER JOIN msdb.dbo.sysjobs J ON Convert(nvarchar(128),R.ScheduleID) = J.name
INNER JOIN msdb.dbo.sysjobschedules JS ON J.job_id = JS.job_id
like image 37
daviesdoesit Avatar answered Oct 23 '22 05:10

daviesdoesit