01.09.2015

Setting unused Reporting Services (SSRS) Reports invisible by script

Technical Value

In this post I'll show you, how an administrator of SQL Server Reporting Services Instance (SSRS) can identify "not used for a while"-reports and set them invisible for the clients. If they are invisible and not missed by any user, you can download the definition, backup it and delete them on the server. Speeding up the browsing the ReportManager.

Giving the situation we have a SQL Server Reporting Services Instance SSRS, the system is running for some years now. And PowerUsers are allowed to develop and deploy reports on the system. The reports are spread over several folders for controlling or sales or marketing and the guys in the logistic centre also need new reports on regular basis. As time goes by there are hundreds of reports deployed, containing names like 'backup' or 'copy', sometimes even 'copy_23' … You know what I mean?

But which of these reports are still in use and which weren't used for long time now. All these reports fill up the folders and users might not know which one is the current one? Now we'd like to tidy up the ReportServerManager and present only the In-Use Reports to the user.

To achieve this we need two information.

  1. which Reports are existing
  2. were they used the last time.

The good thing is we can get this information from the ReportServer-Database. First, let's take a look on the list of all existing reports:

  1. SELECT
  2. [ItemID]
  3. ,[Path]
  4. ,[Name]
  5. ,[ParentID]
  6. ,[Type]
  7. ,[Hidden]
  8. ,[Content]
  9. ,[Intermediate]
  10. ,[SnapshotDataID]
  11. ,[LinkSourceID]
  12. ,[Property]
  13. ,[Description]
  14. ,[CreatedByID]
  15. ,[CreationDate]
  16. ,[ModifiedByID]
  17. ,[ModifiedDate]
  18. ,[MimeType]
  19. ,[SnapshotLimit]
  20. ,[Parameter]
  21. ,[PolicyID]
  22. ,[PolicyRoot]
  23. FROM
  24. [dbo].[Catalog]
  25.  
  26. where Type= 2
  27. /*
  28. Type Name
  29. 1 Folder
  30. 2 Report
  31. 3 Resource
  32. 4 Linked Report
  33. 5 Data Source
  34. 6 Report Model
  35. 8 Datasets
  36. 9 ReportParts */

  Table with Query Results As you can see there is a "Hidden" Column. We get the same view when browsing the folder in the ReportManager: Overview Reports in Report Manager You can set this property in the settings in the ReportManager: Report Details Checking this box will update the Dbo.Catalog-Table: Query Results with Hidden Change And the Report is not shown in the Overview-Page any more: Report Manager Overview without hidden Report Second information we need is when was this report used the last time. In the Report-Server-Default-Setting it tracks all report executions and keeps them for 60 days. You can check and set this option here:

  1. SELECT
  2. [ConfigInfoID]
  3. ,[Name]
  4. ,[Value]
  5. FROM [dbo].[ConfigurationInfo]
  6. where Name like '%Execution%'

Query Results

  1.  

Or Connect the SQL Server Management Studio (SSMS) to the ReportServer Instance, right click on it and select properties. In the dialog select "Logging": Server Properties If this setting is enabled we can use the already existing ExecutionLog-Views in the SSRS. With every new Version of SSRS a new View was added. Views of ExecutionLog To achieve the most downward compatibility I'll use in this post the "dbo.ExecutionLog"

  1. SELECT
  2. [InstanceName]
  3. ,[ReportID]
  4. ,[UserName]
  5. ,[RequestType]
  6. ,[Format]
  7. ,[Parameters]
  8. ,[TimeStart]
  9. ,[TimeEnd]
  10. ,[TimeDataRetrieval]
  11. ,[TimeProcessing]
  12. ,[TimeRendering]
  13. ,[Source]
  14. ,[Status]
  15. ,[ByteCount]
  16. ,[RowCount]
  17. FROM [dbo].[ExecutionLog]

As we know from the configuration above here are all reports listed that were executed within the last 60 days. Having said this, we also know all Reports not listed here were not executed within the last 60 days. Now we know about all the existing Reports and do have information about their executions. Let's combine the information:

  1. SELECT
  2. [ItemID]
  3. ,[Path]
  4. ,[Name]
  5. ,[ParentID]
  6. ,[Type]
  7. ,[Hidden]
  8. ,[Content]
  9. ,[Intermediate]
  10. ,[SnapshotDataID]
  11. ,[LinkSourceID]
  12. ,[Property]
  13. ,[Description]
  14. ,[CreatedByID]
  15. ,[CreationDate]
  16. ,[ModifiedByID]
  17. ,[ModifiedDate]
  18. ,[MimeType]
  19. ,[SnapshotLimit]
  20. ,[Parameter]
  21. ,[PolicyID]
  22. ,[PolicyRoot]
  23. FROM [dbo].[Catalog]
  24. where Type = 2
  25. and ItemId not in (Select ReportId from dbo.ExecutionLog)

This shows the not-used-reports. Using this information in an update-query:

  1. UPDATE [dbo].[Catalog]
  2. SET Hidden = 'true'
  3. WHERE Type = 2 and
  4. ItemId not in (Select ReportId from dbo.ExecutionLog)

And all unused reports are gone (did this for all reports in my example to show the difference) Overview Sample Reports   Experienced readers will now tell me, that this only works in List-View but all Reports are still there in Details-View: Part of Details View That's true: Dateils View   But when you add this small code to your ReportingServices.css file (Default Location: C:\Program Files\Microsoft SQL Server\MSRS12.MSSQLSERVER\Reporting Services\ReportManager\Styles)

  1. #ui_btnSwitchView{ visibility: hidden;}

This option is gone: Hidden Link of Details View Good luck tiding up your Report Server!

Teilen auf

Newsletter Anmeldung

Abonnieren Sie unseren Newsletter!
Lassen Sie sich regelmäßig über alle Neuigkeiten rundum ORAYLIS und die BI- & Big-Data-Branche informieren.

Jetzt anmelden