THE SQL Server Blog Spot on the Web

Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | Join | Help
in Search

Rob Farley

- Owner/Principal with LobsterPot Solutions (a MS Gold Partner consulting firm), Microsoft MVP (SQL Server) and leader of the SQL User Group in Adelaide, Australia.

Re-running SSRS subscription jobs that have failed

Sometimes, an SSRS subscription fails for some reason. It can be annoying, particularly as the appropriate response can be hard to see immediately. There may be a long list of jobs that failed one morning if a Mail Server is down, and trying to work out a way of running each one again can be painful. It’s almost an argument for using shared schedules a lot, but the problem with this is that there are bound to be other things on that shared schedule that you wouldn’t want to be re-run.

Luckily, there’s a table in the ReportServer database called dbo.Subscriptions, which is where LastStatus of the Subscription is stored. Having found the subscriptions that you’re interested in, finding the SQL Agent Jobs that correspond to them can be frustrating.

Luckily, the jobstep command contains the subscriptionid, so it’s possible to look them up based on that. And of course, once the jobs have been found, they can be executed easily enough. In this example, I produce a list of the commands to run the jobs. I can copy the results out and execute them.

select 'exec sp_start_job @job_name = ''' + cast(j.name as varchar(40)) + ''''
from msdb.dbo.sysjobs j 
join  msdb.dbo.sysjobsteps js on js.job_id = j.job_id
join  [ReportServer].[dbo].[Subscriptions] s  on js.command like '%' + cast(s.subscriptionid as varchar(40)) + '%'
where s.LastStatus like 'Failure sending mail%';

Another option could be to return the job step commands directly (js.command in this query), but my preference is to run the job that contains the step.

Published Thursday, March 18, 2010 3:51 PM by Rob Farley
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Nimit Parikh said:

Even better control on re-sending SSRS report on demand see below link

http://www.mssqltips.com/tip.asp?tip=1846

March 18, 2010 8:42 AM
 

Rob Farley said:

Hi Nimit,

Thanks for the link.

The suggestion in that tip is similar to what you get if you return js.command, but my preference is to rerun the job rather than calling the AddEvent procedure.

Rob

March 19, 2010 9:06 PM
 

Jimmy George said:

Hi Gents,

Since all the metadata of the subscription is known, is there a way to insert a subscription directly into these tables and create a job without using SSRS pages.

I am working on a project where all subscription data is maintained in user defined tables.

Thoughts ?

Cheers

Jimmy

March 21, 2010 6:36 AM
 

Nav said:

I got a requirement recently to email the same report to 70 users but before sending, I had to change the user parameter on the report to the specific user and also change the emailid each time before kicking off the subscription. I dint want to create 70 subscritions for same report and just change the user & email id.

So I created a table with the user# and email id and created a sp to loop 70 times and update the subscription table to change the "Parameters" & Extensions fields and then kick off the subscription. Edited the agent job which kicks off the subscription and removed the statement and put a call to the sp. But when I ran the loop was so fast that it just emailed the 70th user with his user report. So I put a wait for 1 minute after each update so that the report finishes the first update and email and then continues. It takes 70 mins for the job to finish but since it runs in the night I am ok with that.

Any other suggesstions?

March 21, 2010 10:17 AM
 

Rob Farley said:

Jimmy & Nav,

Yes, there are lots of ways to skin this particular cat. For the kind of things that you're both describing I prefer to use the SSRS Web Services and call a variety of methods, including Render(). Everything you can do with Report Manager can be done with the Web Services, so it's even very feasible to roll your own Data Driven Subscriptions.

My code is about re-running ones that have failed because of things like a Mail Server outage. If other settings need tweaking I'd go with the Web Services almost every time.

Rob

March 21, 2010 5:25 PM
 

David Leibowitz said:

@Navi:

data.driven.subscriptions.

March 23, 2010 11:13 AM
 

uberVU - social comments said:

This post was mentioned on Twitter by sqlblog: Re-running SSRS subscription jobs that have failed: Sometimes, an SSRS subscription for some reason. It can be ann... http://bit.ly/99KDGe

March 23, 2010 4:13 PM
 

Ian Emery said:

You can use this application to rerun subscriptions- for failed subscriptions and for subscriptions that have not failed and need to rerun for example- a failed ETL process.

September 6, 2010 11:01 AM

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server (Commercial Edition), by Telligent Systems
  Privacy Statement