Search This Blog

Thursday, 30 August 2018

Execute SSRS Subscription on Demand


There could be many ways to fire SSRS subscription but here i will explain how to fire SSRS subscription on demand using RS.EXE utility.

First step is to create your report Subscription through Report Manager using option "New Subscription" or "New Data-driven Subscription" by navigating <Your Report> => Properties => Subscription . Inside your create Subscription, there will be "Select Schedule" button. Click on this button and choose "Once" as option and give any past time under "Start Time" and complete required details for your subscription and click "Ok" button to create your report subscription.


Second step is to create a .RSS file that will be used to trigger newly created subscription in first step. Open Notepad and put below script and save this Notepad file as "..\<Your Folder Path>\Subscription.rss". You can choose any file name with extension .rss

you can put multiple rs.FireEvent statement inside Sub Main block to fire multiple report's subscriptions at the same time.

Sub Main() 
rs.FireEvent("TimedSubscription", "<SubscriptionID>") 
End Sub

Now, we need to get SubscriptionID of newly created subscription in our first step to use it above block (highlighted as yellow). For that, you need to login to Sql Server Management Studio and execute below query on your ReportServer Database.

select s.SubscriptionID,sD.name subscriptionname,c.Name as reportname from Subscriptions s
inner join ReportSchedule RS on RS.SubscriptionID=s.SubscriptionID
inner join Catalog c on c.ItemID=RS.ReportID
inner join Schedule SD on SD.ScheduleID=RS.ScheduleID
where c.Name='<Your Report Name>'

<Your Report Name> will be name your report for that you have created subscription in first step.


Third step to execute .rss file that we created in second step. Again open a new notepad and put below code and save your file as "..\<Your Folder Path>\RunSubscription.bat"

<Full Path of RS.EXE file>\rs.exe -i "..\<Your Folder Path>\Subscription.rss" -s http://<Your Report Server instance name>/reportserver

We are done. you can run your RunSubscription.bat by double click on .bat file.


No comments:

Post a Comment