简体   繁体   中英

How to make SSRS run and send PDF report using one parameter, then change the parameter and run and send another report?

在此处输入图片说明 I have created report in SSRS that subscribed at particular time and sends PDF email. I need exactly the same report, but with different parameter. Is any way to make SSRS automatically change the parameter value, and then send out the PDF report?

Where can I change my parameter here?

I would use a Data-Driven subscription for this. One benefit of data-driven subscriptions is you can give a meaningful description the the subscription instead of it just being "Mail sent to ..."

When you set up the data-driven subscription, step 3 asks for a valid sql query. For every row returned in the sql query, the report will be executed. In your case, your query could be as simple as

select 'Value1' as ParamValue
union select 'Value2'

This will give you two rows, with a different parameter value in each row.

On step 4 you set up the options for recipients, subject line, etc. Note that all of this can also be part of your query.

Step 5 is where you would set up your parameter value, and you'd choose "Get the value from the database" and in the drop-down, select your parameter name.

With it set up this way, the report will be executed twice (once for each row returned in the query from step 3).

One of the main things I use datadriven subscriptions for is when I must send the same report to multiple recipients, but the parameters are different for each recipient. For example, we send a sales report to all of our sales reps. The Sales Rep Code is a parameter for the report but I can customize the other settings for the subscription as well. Using a table containing our sales rep data, I use something like this

SELECT
    SalesRepCode
,   SalesRepEmail
,   'Sales report for ' + SalesRepName + ' - ' + SalesRepCode + ', as of ' + GETDATE() AS SubjectLine
FROM SalesRepTable

This returns around 70 rows, one row for each sales rep. For each row, the report will get generated using the SalesRepCode as a report parameter, the SalesRepEmail as the recipient, and the SubjectLine as the, well, subject line. One subscription, 70 versions of the same 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