SQL 服务器报告服务查询

SQL Server Reporting Services Query

我想要一份关于有多少报告成功、有多少报告失败的报告,并添加报告名称、生成报告的用户、失败原因、报告路径、订阅等信息,时间表,还可以查看历史数据以显示趋势。

我可以使用哪些表格来获取制作报告所需的数据?

我找到了一个查询,它可以提供我做这份报告所需的部分信息,但是它已经过时了,因为它包含的表在 sql-server 的报告服务器数据库中不再存在2012

如有任何帮助或指导,我们将不胜感激。

[Link 到过时的查询] https://social.msdn.microsoft.com/Forums/sqlserver/en-US/c6b35fff-2a46-46ce-bc1e-c166a4d65c2d/ssrs-notification-of-success-or-failure-of-report-generation?forum=sqlreportingservices

[Link 我之前关于这个主题的问题] Incompatible SQL Server Reporting Services Query

这应该有帮助

https://docs.microsoft.com/en-us/sql/reporting-services/report-server/report-server-executionlog-and-the-executionlog3-view

Use ReportServer  
select * from ExecutionLog3 order by TimeStart DESC 


Use ReportServer  
select * from ExecutionLog2 order by TimeStart DESC 

这是我用来搜索报告服务执行日志的查询。此外,还有一些关于 GitHub

的示例报告
DECLARE @all_value AS VARCHAR(10)
DECLARE @LogStatus AS VARCHAR(50)
DECLARE @ReportFolder AS VARCHAR(450)
DECLARE @ReportName AS VARCHAR(450)
DECLARE @UserName AS VARCHAR(260)
DECLARE @StartDate AS DATETIME
DECLARE @EndDate AS DATETIME

SET @all_value = '<ALL>'
SET @LogStatus = '<ALL>' --filter your execution log status here
SET @ReportFolder = '...A Report Folder Name...'
SET @ReportName = '<ALL>' 
SET @UserName = '<ALL>'
SET @StartDate = NULL
SET @EndDate = NULL



;WITH
report_users 
AS
(
    SELECT UserID, UserName, SimpleUserName = UPPER(RIGHT(UserName, (LEN(UserName)-CHARINDEX('\',UserName)))) FROM dbo.Users
)
,
report_catalog
AS
(
    SELECT    
        rpt.ItemID
      , rpt.CreatedById
      , rpt.ModifiedById
      , rpt.[Type]
      , rpt.[Name] 
      , ReportName = rpt.[Name] 
      , rpt.[Description]
      , rpt.Parameter
      , CreationDate = CONVERT(DATETIME, CONVERT(VARCHAR(11), rpt.CreationDate, 13))
      , ModifiedDate = CONVERT(DATETIME, CONVERT(VARCHAR(11), rpt.ModifiedDate, 13))
      , ReportFolder = SUBSTRING(rpt.[Path], 2, Len(rpt.[Path])-Len(rpt.[Name])-2) 
      , rpt.[Path]
      , URL_ReportFolder = 'http://' + Host_Name() + '/Reports/Pages/Report.aspx?ItemPath=%2f'  + SUBSTRING(rpt.[Path], 2, Len(rpt.[Path])-Len(rpt.[Name])-2)  + '&ViewMode=List'
      , URL_Report = 'http://' + Host_Name() + '/Reports/Pages/Report.aspx?ItemPath=%2f'  + SUBSTRING(rpt.[Path], 2, Len(rpt.[Path])-Len(rpt.[Name])-2)  + '%2f' + rpt.[Name]
      , ReportDefinition = CONVERT(VARCHAR(MAX), CONVERT(VARBINARY(MAX), rpt.Content))  
      , HostName = Host_Name()
    FROM 
      dbo.Catalog AS rpt
    WHERE 
      1=1
      AND rpt.[Type] = 2
)
    SELECT 
      ReportPath = rpt.[Path]
    , rpt.ReportFolder
    , ReportName = rpt.[Name]
    , rpt.URL_ReportFolder
    , rpt.URL_Report 
    , URL_Report_Filtered = rpt.URL_Report + '&rs:Command=Render&' + CONVERT(VARCHAR(2000), el.[Parameters])
    , UserName = usr.SimpleUserName
    , el.[Status]
    , el.TimeStart
    , el.[RowCount]
    , el.ByteCount
    , el.[Format]
    , el.[Parameters]
    , TotalSeconds = CONVERT(CHAR(8),DATEADD(ms,(el.TimeDataRetrieval + el.TimeProcessing + el.TimeRendering),0),108)
    , TimeDataRetrieval = CONVERT(CHAR(8),DATEADD(ms,el.TimeDataRetrieval,0),108) 
    , TimeProcessing = CONVERT(CHAR(8),DATEADD(ms,el.TimeProcessing,0),108)  
    , TimeRendering = CONVERT(CHAR(8),DATEADD(ms,el.TimeRendering,0),108) 
    , OrderbyDate = CAST(TimeStart AS DATETIME) 
FROM 
    report_catalog AS rpt 
    LEFT JOIN dbo.ExecutionLog AS el ON el.ReportID = rpt.ItemID
    LEFT JOIN report_users AS usr ON el.UserName = usr.UserName
WHERE 
    1=1
    AND (@all_value IN(@LogStatus) OR el.[Status] IN(@LogStatus))
    AND (@all_value IN(@ReportFolder) OR rpt.ReportFolder IN(@ReportFolder))
    AND (@all_value IN(@ReportName) OR rpt.ReportName IN(@ReportName))
    AND (@all_value IN(@UserName) OR usr.SimpleUserName IN(@UserName))
    AND (@StartDate IS NULL OR CONVERT(DATETIME, CONVERT(VARCHAR(11),el.TimeStart,13)) >= @StartDate)
    AND (@EndDate IS NULL OR CONVERT(DATETIME, CONVERT(VARCHAR(11),el.TimeStart,13)) <= @EndDate)