我需要一个查询来识别SSRS中的所有数据驱动订阅。有谁知道这是否可能?我查看了订阅表,我只看到EVENTTYPE ='定时订阅'。
答案 0 :(得分:4)
这应提供数据驱动的订阅列表。
SELECT s.*
FROM dbo.Subscriptions AS s
WHERE s.DataSettings IS NOT NULL;
答案 1 :(得分:1)
如果可以避免,请不要使用查询到报表服务器的数据库。无法保证版本之间保持不变,在最坏的情况下,查询它实际上可能会干扰报表服务器操作。
使用API,通过编写适当的代码来调用程序中的Web服务或使用RS.exe(请参阅Script with the rs.exe Utility and the Web Service)。
以下是与RS.exe一起使用的脚本,您应该能够轻松地适应您的需求。您应该在作为报表服务器管理员的用户帐户下运行它。
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