简体   繁体   中英

Executing SSRS Reports From SSIS

I need to execute a SSRS reports from SSIS on periodic schedule.

Saw a solution here :

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 ? I don't quite understand the script and concern there could be some support issue for me.

Database : SQL Server 2008R2 Standard Edition

Any ideas ? Thanks very much ...



This assumes that the SSIS job will have updated a control record or written some other identifiable record to a database.

1. Create a subscription for the report.
2. Run this SQL to get the GUID of the report

 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.

a. Step 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"

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

b. Step 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.

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. 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.

You can get the Subscription ID from the Report Server database. It is in the Subscriptions table. Use this query to help locate the subscription:

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

FROM Catalog

INNER JOIN Subscriptions ON Catalog.ItemID = Subscriptions.Report_OID

In SSIS, you can use this statement, inside of a SQL Task, to fire the subscription:

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

Hope this helps.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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