确定已运行超过5分钟的SSRS报告

时间:2017-07-28 17:46:53

标签: sql-server reporting-services sql-server-2012 ssrs-2012

我想确定哪些SSRS报告已在5分钟内运行但仍在运行

SSRS执行日志仅在报告加载后显示一个条目,而下面的查询没有显示长时间运行查询的来源,因此我无法将其与报告联系起来。

我想用它来杀死长时间运行报告的spid。 [SQL Server 2012]

有人可以帮忙吗?

 SELECT  st.text,
            qp.query_plan,
            qs.*
    FROM    (
        SELECT  TOP 50 *
        FROM    sys.dm_exec_query_stats
        ORDER BY total_worker_time DESC
    ) AS qs
    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st
    CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp
    WHERE qs.max_worker_time > 300
          OR qs.max_elapsed_time > 300 

3 个答案:

答案 0 :(得分:0)

安装Reporting Services后,您可以查询一个runningjobs表。警告:你有什么版本的SQL Server?

USE ReportServer;

DECLARE @cutoff DATETIME;
SET @cutoff = DATEADD(minute, -5, GETDATE()); --Five minutes ago

SELECT JobID, JobType, JobStatus, RequestName, StartDate 
FROM RunningJobs
WHERE StartDate < @cutoff --prunes records that haven't run for five minutes yet
ORDER BY StartDate --oldest first

答案 1 :(得分:0)

这里有一些可能有助于解决慢速SSRS报告的阅读 https://technet.microsoft.com/en-us/library/bb522806(v=sql.105).aspx

https://www.mssqltips.com/sqlservertip/2328/sql-server-reporting-services-reports-performance-debugging-and-analysis/

Fast query runs slow in SSRS

SELECT TOP 1000 * FROM[ReportServer].[dbo].[ExecutionLog2]

SELECT TOP 1000 * FROM[ReportServer].[dbo].[ExecutionLog3]

或者您可以利用RedGate对SQL Monitor进行为期14天的免费试用 http://www.red-gate.com/dynamic/products/dba/sql-monitor/download

答案 2 :(得分:0)

我假设您正在通过SQL Server代理作业运行这些报告。 而且,这就是我正在使用的,

 SELECT
   *
FROM
    msdb.dbo.sysjobs_view job 
        INNER JOIN msdb.dbo.sysjobactivity activity
        ON (job.job_id = activity.job_id)
WHERE

       run_Requested_date>dateadd(MINUTE,-5,getdate())
    AND stop_execution_date is null)