[英]Find existing data driven subscription in reportserver
I am in need of a query to identify all data driven subscriptions in SSRS. 我需要一个查询来识别SSRS中所有数据驱动的订阅。 Does anyone know if that is possible? 有人知道这是否可能吗? I looked into subscription table and I only see EVENTTYPE = 'Timed Subscription'. 我查看了订阅表,只看到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. 无法保证它在版本之间将保持不变,并且在最坏的情况下,查询它实际上可能会干扰Report Server的操作。
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 ). 通过编写适当的代码以在程序中调用Web服务或使用RS.exe来使用API,(请参阅rs.exe实用程序和Web服务中的脚本 )。
Below is a script for use with RS.exe that you should be able to easily adapt to your needs. 下面是与RS.exe一起使用的脚本,您应该可以轻松地适应自己的需求。 You should run this under a user account that is an administrator of the Report Server. 您应该在作为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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.