SSRS Data Driven Subscription Query

Is it possible to pass the report name in a data-driven subscription query for a "save to network share" job?

I want to create a table that contains the titles all of my reports, their respective file paths, default output formats, etc.  I plan to use a query that would return the details based on where the report name equals the name in the table.  This way I enter the same query across all of the subscriptions and it would work regardless of which report it is tied to.

Ex.

Select rpt_name, filepath, ouput_fmt

From rpt_tbl_list

Where rpt_name = <report name>

I tried the "@reportname" that is used when the report is emailed but it doesn't seem to work when you want to save the file to a network share.  When I entered the "@reportname" into the query box, the query validation failed.

Thanks.

July 10th, 2015 1:26pm

Hi mchiass,

According to your description, you want to use @ReportName variable in a file share data driven subscription query, right?

In Reporting Services, when we define a query to retrieve subscriber data from the database, if the query contains a variable, we must declare it in the query. Though the variable @ReportName is a built in field in the report, its not supported to use it directly in the subscription query. The query written in this section is the same as we write in the SSMS. About any variable, we must declare then use it.

Reference:
Transact-SQL Variables

If you have any question, please feel free to ask.

Best regards,
Qiuyun Yu

If you have any feedback on our support, please click her

July 13th, 2015 1:32am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics