Solved

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

Posted on 2014-12-02
4
123 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

772 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