![]() |
|
|
|
By: Sankar Reddy | Read Comments (15) | Related Tips: > Reporting Services Monitoring |
Problem
Our company has hundreds of SQL Server Reporting Services reports with daily, weekly, monthly, quarterly, yearly and adhoc schedules with various rendering formats like web archive, excel, pdf, csv, xml and tiff sent to multiple users, departments and groups. Sometimes we have to manually run a subscription to resend reports on an adhoc basis or re-send the reports when the actual subscriptions failed or when the data had to be corrected.
In this tip I will show you an easy way to identify the scheduled Reporting Services report, so you can run that scheduled job to reproduce the reports and delivery of the reports.
Solution
SQL Server Reporting services has come a long way from the first time it was released for SQL Server 2000 SP4. Unfortunately there are still some rough corners where it could be improved and one such place is subscriptions.
Manually initiating a subscription is a tedious task in SQL Server Reporting Services. Each subscription in Reporting Services is setup as a SQL Server Agent job, but the job names are NOT intuitive, rather named as a Unique Identifier as shown below.
Here is a screenshot of some of the subscriptions on a Reporting Services instance.

Option 1:
This method looks at the dbo.ReportSchedule, dbo.Subscriptions, dbo.Catalog tables of the ReportServer database along with the dbo.sysjobs table of the msdb to figure out the SQL Agent job name. Additional information is also pulled to isolate the correct report when a similarly named report is in multiple folders/paths.
|
From the above resultset, grab the uniqueidentifier for the JobName column and filter the job in SSMS as shown below. Once the correct job is identified, run the SQL Server Agent job to deliver the subscription.

Option 2:
This option is better than the first option and completely eliminates the manual step in Option 1 of having to find and run the SQL Agent job.
In this option, we will generate the T-SQL that is used inside the SQL Agent job directly from the tables and then just run the SQL. It's a pure SQL based solution.
After you run this query, get the column that has the EXEC command for the report you want to re-run and paste the EXEC command into a query window to execute the code to re-run the report.
|
Next Steps:
| Monday, September 28, 2009 - 6:28:29 AM - WelshGandalf | Read The Tip |
|
This would be really useful to me but your code in part 2 sometimes gives some results (but not a full set) and always gives me the following error message... Can you help with this? I'm unfamiliar with the tables in the ReportServer database so would find it difficult to diagnose the problem myself. |
|
| Monday, September 28, 2009 - 8:04:31 AM - SankarReddy | Read The Tip |
|
Hi Welsh, If you don't mind, can you send me the version of SQL Server [use SELECT @@VERSION] and a screenshot if possible to my email id at SankarAThotmailDOTcom. We can post the findings once we identify the root cause here.
|
|
| Monday, September 28, 2009 - 11:28:30 AM - SankarReddy | Read The Tip |
Hi Welsh,
I am able to reproduce the problem you are facing. This happens when you install reporting services on the same box and you have other SQL Jobs created.
To fix the error, you need to add an extra condition like below to the where clause. I have sent the update to Greg and hopefully the post will be updated.
b.description = 'This job is owned by a report server process. Modifying this job could result in database incompatibilities. Use Report Manager or Management Studio to update this job.'
|
|
| Tuesday, September 29, 2009 - 12:44:07 AM - WelshGandalf | Read The Tip |
|
Thanks a lot, yes that's the setup I have and your fix make it work just fine now :) |
|
| Wednesday, September 30, 2009 - 1:14:59 PM - jerryhung | Read The Tip |
|
I got duplicate on SOME reports with the original query posted I think it's from the "old/deleted" subscription and the double-join between table a and c (ReportServer.dbo.ReportSchedule)
This one works for me --http://www.mssqltips.com/tip.asp?tip=1846 |
|
| Thursday, October 08, 2009 - 2:06:56 PM - erutledge | Read The Tip |
|
This is great for figuring out what is what, but is there a way to permanently change the SQL Server agent Job Name? Just by finding the name of the job, then updating the column in that table? Thanks! |
|
| Thursday, October 08, 2009 - 2:15:53 PM - SankarReddy | Read The Tip |
|
You certainly don't want to do that. On a related note, here is the MSFT recommendation. Here is a quote from BOL: The table structure for both databases is optimized for server operations and should not be modified or tuned. Microsoft might change the table structure from one release to the next. If you modify or extend the database, you might limit or prevent the capability to perform future upgrades or apply service packs. You might also introduce changes that impair report server operations. http://technet.microsoft.com/en-us/library/ms156016.aspx
|
|
| Sunday, March 21, 2010 - 6:25:57 AM - benjim | Read The Tip |
|
Since all the metadata is identified for a subscription report, is there a way to insert a subscription and a schedule into these tables without going through the SSRS pages. I am working on a project were subscriptin details are maintained in user defined tables.
Any suggestions ?
Jimmy
|
|
| Tuesday, June 12, 2012 - 12:26:14 PM - Surbhi | Read The Tip |
|
Hi Benjim,
Were u able to do maintain ubscriptions and related schedule for a reports? I am currently working on same kind of project, where, I have to update schedule for a subscription of report using my application and update the tables of reportserver db from backend and ASP.Net. Please share the details if you were able to complete your project.
|
|
| Monday, June 25, 2012 - 4:14:43 PM - aas4mis | Read The Tip |
|
Always funny how somebody opens an old thread days before I need it. At any rate, I was getting conversion errors when I ran this (conversion failed when converting from a character string to uniqueidentifier). This is in the joins to b.name. Convert a.ScheduleID and C.ScheduleID to varchar for a proper join. Hope this helps somebody. BTW,
--aas4mis |
|
| Monday, July 23, 2012 - 4:45:26 AM - Mayan | Read The Tip |
|
Your query really helped me track failed subscriptions and rerun them. (with the first 5 remarks updates too). Thanks a lot! |
|
| Thursday, August 02, 2012 - 1:42:57 PM - Priya | Read The Tip |
|
Very helpful tip..Thanks for you help Sankar |
|
| Monday, August 20, 2012 - 12:55:29 PM - Ludwig Guevara | Read The Tip |
|
With the following sql statement will show you the definition for each report, if the report is using a store procedure or a SQL statement, Of course, If your Reporting Services instance has a different name, you'll need to change the bold name --Find the procedure names that are being used along with report, datasource names
USE ReportServer --Find the relationship between a report and a DataSet
|
|
| Tuesday, October 16, 2012 - 6:08:50 AM - Mayan | Read The Tip |
|
I changed the EXEC part in order to be able to rerun caching etc. which failed too:
SELECT
'EXEC ReportServer.dbo.AddEvent @EventType=''' + eventtype +''',@EventData='''+ +CAST(a.SubscriptionID ASVARCHAR(40))+''''AS ReportCommand |
|
| Monday, October 29, 2012 - 12:07:11 AM - Brahadesh Ramamurthy | Read The Tip |
|
SELECT
Cast(b.name as Uniqueidentifier) AS JobName
, e.name
, e.path
, d.description
, a.SubscriptionID
, laststatus
, eventtype
, LastRunTime
, date_created
, date_modified
FROM ReportServer.dbo.ReportSchedule a JOIN msdb.dbo.sysjobs b
ON Cast(a.ScheduleID as nvarchar(50)) =CAST(b.name as nvarchar(50))
JOIN ReportServer.dbo.ReportSchedule c
ON Cast(b.name as nvarchar(50)) = cast(c.ScheduleID as nvarchar(50))
JOIN ReportServer.dbo.Subscriptions d
ON Cast(c.SubscriptionID as nvarchar(50)) = Cast(d.SubscriptionID as nvarchar(50))
JOIN ReportServer.dbo.Catalog e
ON Cast(d.report_oid as nvarchar(50)) = Cast(e.itemid as nvarchar(50))
WHERE e.name = 'Sales'
|
|
|
privacy | disclaimer | copyright | advertise | about authors | contribute | feedback | giveaways | user groups Some names and products listed are the registered trademarks of their respective owners. Edgewood Solutions LLC | MSSharePointTips.com | MSSQLTips.com |