Solved

How to maintain SQL Server Reporting Services job subscription in SQL Server Agent job history

Posted on 2014-12-02
4
91 Views
Last Modified: 2016-06-16
SSRS subscription jobs under SQL Server AgentUsing SQL Server 2008 R2 and SQL Server Reporting Services (SSRS)

When I schedule an SSRS report in SQL Server Reporting Services - Report Manager, it creates a subscription in SSRS.
In Microsoft SQL Server Management Studio under SQL Server Agent a new Job is added with a cryptic job name.
Please see attached snapshot for example.

How do I clean up those SSRS subcription jobs under SQL Server Agent?
For example, what if I only wanted to maintain 30 days worth of job history?
What procedure do I follow?

Thank you.

ssrs1212014
0
Comment
Question by:ssrs1212014
4 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 250 total points
ID: 40478015
That "cryptic job name" is called a GUID, or a uniqueidentifier.

To limit the job history:

Right-hand click on SQL Server Agent
Go to Properties
Go to History

There you can limit the maximum job history log size (in rows), the maximum rows per job, and remove agent history older than X days/weeks/months.
0
 

Author Comment

by:ssrs1212014
ID: 40478437
thank you Phillip.
0
 
LVL 28

Assisted Solution

by:Ryan McCauley
Ryan McCauley earned 250 total points
ID: 40528363
Many of those SQL Agent jobs may be for expired subscriptions or no longer valid - we use the following query to determine if they can be safely removed:

   select c.Name as ReportName,
                  s.EventType,
                  s.Description as SubscriptionDescription,
                  s.LastStatus as LastSubscriptionStatus,
                  s.LastRunTime SubscriptionLastRunTime,
                  case
                     when recurrencetype = 1 then 'One Time'
                     when recurrencetype = 2 then 'Hourly'
                     when recurrencetype = 4 then 'Daily'
                     when recurrencetype = 5 then 'Monthly' 
                     when recurrencetype = 6 then 'Month Week' 
                     else 'Other'
                  end as RecurranceType,
                  s.DeliveryExtension,
                  u.UserName as SubscriptionSetUpBy,
                  s.ModifiedDate as SubscriptionLastModifiedDate
             from [ReportServer].[dbo].[Subscriptions] s
             join [ReportServer].[dbo].[Catalog] c
               on c.ItemID = s.Report_OID
             join [ReportServer].[dbo].[Users] u
               on u.UserID = s.OwnerID
             join [ReportServer].[dbo].[reportschedule] rs
               on c.itemid = rs.reportid 
              and s.subscriptionid = rs.subscriptionid
             join [ReportServer].[dbo].[schedule] sch
               on rs.scheduleid = sch.scheduleid
            where s.EventType <> 'RefreshCache'
              and s.LastRunTime < dateadd(m,-3,getdate())
         order by c.name

Open in new window


It will list any jobs that haven't been executed in the past three months, and you can likely remove any of those safely (though it includes Username, so you can contact them to ensure it's not necessary to keep).
1

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now