简体   繁体   English

从 SSIS 执行 SSRS 报告

[英]Executing SSRS Reports From SSIS

I need to execute a SSRS reports from SSIS on periodic schedule.我需要定期从 SSIS 执行 SSRS 报告。

Saw a solution here :在这里看到了一个解决方案:

https://www.mssqltips.com/sqlservertip/3475/execute-a-sql-server-reporting-services-report-from-integration-services-package/ https://www.mssqltips.com/sqlservertip/3475/execute-a-sql-server-reporting-services-report-from-integration-services-package/

But is there any other option in SSIS without using Script Task ?但是在不使用 Script Task 的情况下,SSIS 中还有其他选项吗? I don't quite understand the script and concern there could be some support issue for me.我不太了解脚本,并且担心我可能会遇到一些支持问题。

Database : SQL Server 2008R2 Standard Edition数据库:SQL Server 2008R2 标准版

Any ideas ?有任何想法吗 ? Thanks very much ...非常感谢 ...

SSIS controlling the running of an SSRS in SQL Agent. SSIS 控制 SQL 代理中 SSRS 的运行。

This assumes that the SSIS job will have updated a control record or written some other identifiable record to a database.这假定 SSIS 作业将更新控制记录或将一些其他可识别记录写入数据库。

1. Create a subscription for the report. 1. 为报告创建订阅。
2. Run this SQL to get the GUID of the report 2. 运行此 SQL 以获取报表的 GUID

 SELECT  c.Name AS ReportName
  , rs.ScheduleID AS JOB_NAME
  , s.[Description]
  , s.LastStatus
  , s.LastRunTime
FROM 
  ReportServer..[Catalog] c 
  JOIN ReportServer..Subscriptions s ON c.ItemID = s.Report_OID 
  JOIN ReportServer..ReportSchedule rs ON c.ItemID = rs.ReportID
  AND rs.SubscriptionID = s.SubscriptionID<br>

3. Create a SQL Agent job. 3. 创建 SQL 代理作业。

a.一个。 Step 1.步骤1。

A SQL statement to look for data in a table containing a flagged record where the Advanced setting is "on failure end job reporting success"用于在包含标记记录的表中查找数据的 SQL 语句,其中高级设置为“失败结束作业报告成功”

IF NOT exists ( select top 1 * from mytable where mykey = 'x' 
and mycondition = 'y') RAISERROR ('No Records Found',16,1)

b.湾。 Step 2第2步

USE msdb 
EXEC sp_start_job @job_name = ‘1X2C91X5-8B86-4CDA-9G1B-112C4F6E450A'<br>

Replacing the GUID with the one returned from your GUID query.将 GUID 替换为从您的 GUID 查询返回的 GUID。

One thing to note though ... once the report subscription has been executed then as far as SQL Agent is concerned then that step is complete, even though the report has not necessarily finished running.不过要注意的一件事......一旦执行了报告订阅,那么就 SQL 代理而言,即使报告不一定完成运行,该步骤也完成了。 I once had a clean up job after the Exec step which effectively deleted some of my data before the report reached it!我曾经在执行步骤之后进行了一项清理工作,该工作在报告到达之前有效地删除了我的一些数据!

You can create a subscription for the report that is never scheduled to run.您可以为从未计划运行的报告创建订阅。

If you have the Subscription ID, you can fire the report subscription using a simple SQL Task in SSIS.如果您有订阅 ID,则可以使用 SSIS 中的简单 SQL 任务触发报告订阅。

You can get the Subscription ID from the Report Server database.您可以从报表服务器数据库中获取订阅 ID。 It is in the Subscriptions table.它位于订阅表中。 Use this query to help locate the subscription:使用此查询来帮助定位订阅:

SELECT Catalog.Path ,Catalog.Name ,SubscriptionID ,Subscriptions.Description SELECT Catalog.Path ,Catalog.Name ,SubscriptionID ,Subscriptions.Description

FROM Catalog来自目录

INNER JOIN Subscriptions ON Catalog.ItemID = Subscriptions.Report_OID Catalog.ItemID = Subscriptions.Report_OID 上的 INNER JOIN 订阅

In SSIS, you can use this statement, inside of a SQL Task, to fire the subscription:在 SSIS 中,您可以在 SQL 任务中使用此语句来触发订阅:

 EXEC reportserver.dbo.AddEvent @EventType='TimedSubscription',@EventData=  [Your Subscription ID]

Hope this helps.希望这可以帮助。

我有同样的问题,我必须使用 ssis 从报告中导出报告,因为渲染不支持 excel 中的大量记录,例如 100.000 条记录,因此订阅的渲染有超时错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM