I am in need of a query to identify all data driven subscriptions in SSRS. Does anyone know if that is possible? I looked into subscription table and I only see EVENTTYPE = 'Timed Subscription'.
This should provide a list of subscriptions that are data-driven.
SELECT s.*
FROM dbo.Subscriptions AS s
WHERE s.DataSettings IS NOT NULL;
Don't use queries to the Report Server's database if you can avoid it. There are no guarantees that it will stay the same between versions and, in the worst case, querying it could actually interfere with Report Server operations.
Use the API instead, either by writing the appropriate code to call the web services in a program or using RS.exe (See Script with the rs.exe Utility and the Web Service ).
Below is a script for use with RS.exe that you should be able to easily adapt to your needs. You should run this under a user account that is an administrator of the Report Server.
Public Const vbTab As String = Microsoft.VisualBasic.Constants.vbTab
Public Function ListCatalogItems() As [CatalogItem]()
Dim items As [CatalogItem]() = Nothing
Try
items = rs.ListChildren("/", true)
Catch ex As System.Web.Services.Protocols.SoapException
Console.Error.WriteLine(ex.Detail.InnerXml)
Catch e as Exception
Console.Error.WriteLine(e.Message)
End Try
Return items
End Function
Public Function GetSubscriptions(itemPath As String) As [Subscription]()
Dim subscriptions As [Subscription]() = Nothing
Try
subscriptions = rs.ListSubscriptions(itemPath, Nothing)
Catch ex As System.Web.Services.Protocols.SoapException
Console.Error.WriteLine(ex.Detail.InnerXml)
Catch e as Exception
Console.Error.WriteLine(e.Message)
End Try
Return subscriptions
End Function
'rs -i GetSubscriptions.rsvb -s http://MyReportServer/ReportServer
Public Sub Main()
Console.WriteLine()
Console.WriteLine("Getting list of items from server...")
Dim items As [CatalogItem]() = ListCatalogItems()
If items Is Nothing OrElse items.Length = 0 Then
Console.WriteLine(String.Format("{0}There are no folders to process.", vbTab))
Else
Console.WriteLine("Checking Items for subscriptions...")
For Each item As [CatalogItem] In items
If item.Type = ItemTypeEnum.Report
Dim subscriptions As [Subscription]() = GetSubscriptions(item.Path)
For Each subscriptionItem As [Subscription] In subscriptions
Dim subscriptionType As String = "Subscription"
If subscriptionItem.IsDataDriven = True Then
subscriptionType = "Data driven subscription"
End If
Console.WriteLine(String.Format("{0} {1} {2} owned by {3} on report {4}.", vbTab, subscriptionType, subscriptionItem.SubscriptionID,
subscriptionItem.Owner, subscriptionItem.Report))
Next
End If
Next
End If
Console.WriteLine("Done.")
Console.WriteLine()
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.