Solved

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

Posted on 2014-12-02
4
185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

636 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