Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Data Management

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

    Search

    XML Feeds

    Google Ads

    « The Productive DBAUpgrading the DBA »
    comments

    For every instance of SQL Server Reporting Services (2005+) there are two databases, a primary and a TempDB. The primary database holds all of the data for your instance, such as: Users, Folder Structure, Roles, Security, Subscriptions, Data Sources, etc. There a lot of data here that you can use to clean up your Reporting Services instances, or help keep them in order. Also, from my experience the database doesn’t change much from 2005 to 2008, so these should work on both versions. I’d be willing to bet they’ll work on 2008 R2 as well. If they don’t, let me know.

    The very first view I made using data from the Reporting Services database was a list of Report Executions. This view was great because I could see which reports were actually being used and which weren’t, and who was using which reports. I made a report off of this view and provided it to a manager so they could track to make sure the other managers were checking their employee hours report.

    1. CREATE VIEW [dbo].[ExecutionLogView]
    2. AS    SELECT TOP (100) PERCENT
    3.             dbo.ExecutionLog.UserName,
    4.             dbo.Catalog.Path,
    5.             dbo.Catalog.Name,
    6.             dbo.ExecutionLog.TimeStart,
    7.             dbo.ExecutionLog.TimeDataRetrieval
    8.       FROM
    9.             dbo.ExecutionLog
    10.             INNER JOIN dbo.Catalog
    11.                   ON dbo.ExecutionLog.ReportID = dbo.Catalog.ItemID
    12.       ORDER BY
    13.             dbo.ExecutionLog.TimeStart DESC

    One of the issues I had with one of my instances was subscriptions. There were scheduled subscriptions everywhere and a lot of them ran at the same time, but they weren’t on a shared schedule.

    1. create view dbo.ReportSubscriptionView
    2. as
    3. SELECT TOP (100) PERCENT
    4.       dbo.Catalog.ItemID as ReportID,
    5.       dbo.Catalog.Path,
    6.       dbo.Catalog.Name,
    7.       dbo.Catalog.Description,
    8.       dbo.Catalog.Hidden,
    9.       dbo.Subscriptions.SubscriptionID,
    10.       dbo.Subscriptions.OwnerID,
    11.       dbo.Subscriptions.Description AS SubscriptionDesc,
    12.       dbo.Subscriptions.LastStatus,
    13.       dbo.Subscriptions.EventType,
    14.       dbo.Subscriptions.LastRunTime,
    15.       dbo.Subscriptions.Parameters,
    16.       dbo.Subscriptions.DataSettings,
    17.       dbo.Subscriptions.DeliveryExtension,
    18.       dbo.ReportSchedule.ScheduleID,
    19.       dbo.Schedule.Name AS ScheduleName,
    20.       dbo.Schedule.NextRunTime,
    21.       dbo.Schedule.LastRunTime AS LastScheduleRun,
    22.       dbo.Schedule.EndDate,
    23.       dbo.Schedule.MinutesInterval,
    24.       dbo.Schedule.DaysInterval,
    25.       dbo.Schedule.WeeksInterval,
    26.       dbo.Schedule.DaysOfWeek,
    27.       dbo.Schedule.DaysOfMonth,
    28.       dbo.Schedule.Month,
    29.       dbo.Schedule.MonthlyWeek,
    30.       dbo.Schedule.EventType AS ScheduleType,
    31.       dbo.Schedule.ConsistancyCheck,
    32.       dbo.Users.UserName as ModifiedBy
    33. FROM
    34.       dbo.Subscriptions
    35.       INNER JOIN dbo.Catalog
    36.             ON dbo.Subscriptions.Report_OID = dbo.Catalog.ItemID
    37.       INNER JOIN dbo.Schedule
    38.       INNER JOIN dbo.ReportSchedule
    39.             ON dbo.Schedule.ScheduleID = dbo.ReportSchedule.ScheduleID
    40.             ON dbo.Subscriptions.SubscriptionID = dbo.ReportSchedule.SubscriptionID
    41.       INNER JOIN dbo.Users
    42.             ON dbo.Subscriptions.ModifiedByID = dbo.Users.UserID
    43. ORDER BY
    44.       dbo.Catalog.Path,
    45.       dbo.Catalog.Name

    I discovered that SSRS creates a SQL Agent Job for every schedule subscription that isn’t on a shared subscription, which explained the Job explosion I had as well on the server. I went snooping and discovered that the Job that SSRS created is named the same as the ScheduleID in the above view. I used that view and that knowledge to create a few shared schedules and then using the view I found all of the relevant subscriptions in Report Manager and updated them to use the shared subscription. This reduced the number of jobs I had, and the number of different subscriptions I had. I was also able to identify subscriptions that were no longer used.

    One other view that I found useful was a view of the whole directory and the related security.

    1. create view [dbo].[CatalogSecurity] as
    2. select  top (100) percent
    3.     c.ItemID,
    4.     c.Path,
    5.     c.Name,
    6.     c.Type,
    7.     c.PolicyID,
    8.     u.UserName,
    9.     r.RoleName
    10. from dbo.Catalog c
    11.     left outer join dbo.PolicyUserRole pcr
    12.         on c.PolicyID=pcr.PolicyID
    13.     left outer join dbo.Users u
    14.         on pcr.UserID=u.UserID
    15.     left outer join dbo.Roles r
    16.         on pcr.RoleID=r.RoleID
    17. order by Path, Type, UserName, RoleName

    With this view, I could see who all had what rights to specific folders and reports. One of my initiatives has been to remove security from a by-report policy to a by-folder policy, making security a lot easier to manage.

    Well, those are the main ones I’ve used. If you’ve got other useful views into the Reporting Services data, let me know, I’d love to see them.

    About the Author

    I have an A.S. in Computer Programming. I am currently a Database Developer (April 2008-Present) for a development group at a contract research lab, where we build in-house applications using Microsoft SQL Server (2005 and 2008) and ASP.Net 3.5. I have a part-time job (April 2007-Present) as a dba/db developer/web developer/designer. I use: SQL Server 2005/08/R2, HTML, CSS, PHP, and Java Script. Penguins are awesome, but I'm not a linux person. If you have any questions feel free to email me at dforck@gmail.com
    Social SitingsTwitterFacebookLTD RSS Feed
    Instapaper

    1 comment

    Comment from: SQLDenis [Member] Email
    SQLDenis You know that those views won't be sorted right? Since SQL Server 2005 this has changed, see here: Create a sorted view in SQL Server 2005 and SQL Server 2008
    11/19/10 @ 15:52

    Leave a comment


    Your email address will not be revealed on this site.

    Your URL will be displayed.
    (Line breaks become <br />)
    (Name, email & website)
    (Allow users to contact you through a message form (your email will not be revealed.)