Dynamically Set the to Address in SSRS reports Subscription

℡╲_俬逩灬. 提交于 2019-12-01 21:14:27

Sounds like you need to set up a data driven subscription which is available with the enterprise edition of SSRS 2012.

Create the report with a User parameter that will create your list of items attached to an email addresses.

When you then create the data driven subscription you get the opportunity to create another SQL statement that can be used for addressees and to get values to pass as parameters to your report.

If your proc is created something like (yours will probably be a little more complex...)

CREATE PROC GetAssigned 
          @EmailAddress nvarchar(255)
As

IF @EmailAddress is Not null
    SELECT EmailAddress,Item1,Item2
    FROM MyTable
    WHERE EmailAddress = @EmailAddress
ELSE
    SELECT DISTINCT EmailAddress FROM myTable

You can run this proc in both the report and as the data driven subscription to get the list of email addresses to send and as the parameter to the report. (Although you could just add the SELECT DISTINCT query to the box below rather than having it in the proc?)

To set up the Subscription (Enterprise version, right?)

Although, you could just enter the script in the box above.

SELECT DISTINCT EmailAddress from MyTable
  • Then on the next screen when Entering recipients use the value returned by the proc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!