Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to shrink a transaction log file down to a reasonable size.

914 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

22 Experts available now in Live!

Get 1:1 Help Now