简体   繁体   中英

SSRS 2016 Report Schedule - T-SQL trigger

I've several SSRS subscriptions set up which are run on demand via (this just triggers a pre-existing schedule)

EXEC msdb.dbo.sp_start_job = '0B5B5AB1-F475-4478-A3DA-3D602C4FDA4C'

What I'd ideally like to do is have one SSRS subscription that I can pass multiple times with different parameter values via a stored procedure, currently the values are set up in the subscription itself.

As an example, I have a report with a @Client parameter and 3 clients, 123, 124 and 125.

So I run a stored procedure that would execute the SSRS subscription and pass the specified parameter. ie - 123. Example below-

EXEC msdb.dbo.sp_start_job = '0B5B5AB1-F475-4478-A3DA-3D602C4FDA4C' @Client = 123

however I cannot find a method that will work

I might not have understood your problem fully, so apologies in advance if I take you down a rabbit hole. Having said that..

Given your situation, this is how I would set up my reports and their subscriptions.

I would place parameter @Client in the report, and get it's values from a table lets call it Client_Table that contains one attribute ClientCode , which will drive what data is selected in the report.

I would then create a stored procedure which will have EXEC msdb.dbo.sp_start_job = '0B5B5AB1-F475-4478-A3DA-3D602C4FDA4C' nested inside it, but would truncate the table that contains the values of @Client , for only the client that you want that particular execution of the report for. Something like this..

create proc ProcNameHere @ClientID int

as

truncate table Client_table --Truncate values from previous run

Insert Client_Table 
Select @ClientID --add ClientID for this run

EXEC msdb.dbo.sp_start_job = '0B5B5AB1-F475-4478-A3DA-3D602C4FDA4C' -- run the report that takes clientid from Client_ID table 

Let me know if this is what you meant.

This way you can use EXEC ProcNameHere '123' to run the report for client 123, as that will be the only entry in the table that is driving the client selection within the report.

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