简体   繁体   English

SSRS 2016报告时间表-T-SQL触发器

[英]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) 我已经设置了几个SSRS订阅,这些订阅通过按需运行(这会触发预先存在的时间表)

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. 我理想地要做的是拥有一个SSRS订阅,我可以通过存储过程多次传递具有不同参数值的值,当前这些值是在订阅本身中设置的。

As an example, I have a report with a @Client parameter and 3 clients, 123, 124 and 125. 例如,我有一个带有@Client参数和3个客户端123、124和125的报告。

So I run a stored procedure that would execute the SSRS subscription and pass the specified parameter. 因此,我运行了一个存储过程,该过程将执行SSRS订阅并传递指定的参数。 ie - 123. Example below- 即-123。以下示例-

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. 我将参数@Client放在报表中,并从表中获取其值,然后将其命名为Client_Table ,其中包含一个属性ClientCode ,该属性将驱动报表中选择的数据。

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. 然后,我将创建一个存储过程,该存储过程将嵌套有EXEC msdb.dbo.sp_start_job = '0B5B5AB1-F475-4478-A3DA-3D602C4FDA4C' ,但将截断包含@Client值的@Client ,仅适用于该客户端您想要报告的特定执行。 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. 这样,您可以使用EXEC ProcNameHere '123'运行客户端123的报告,因为这将是表中唯一驱动报告内客户端选择的条目。

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

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