BI SQL # 197 : SQL Server DBA Scripts : Overview of all objects created in SSRS ordered by the folder hierarchy
Hi Folks,
In this article we are going to cover Overview of all objects created in SSRS ordered by the folder hierarchy.
In this post we are going to discuss following points:
- Problem Statement of SQL Script:
- Description of SQL Script:
- SQL Script Output Column
- Input Parameter of SQL Script
- SQL Script Code
- SQL Script Output Screenshot
- User Level to execute
Problem Statement of SQL Script:
How to view all objects created in SSRS ordered by folder hierarchy through Script?
Description of SQL Script:
This script will help in getting an overview of all objects created in SSRS ordered by the folder hierarchy.
SQL Script Output Column
Input Parameter of SQL Script
Run this script directly on Report Server Database.
SQL Script Code
DECLARE @url NVARCHAR(100); SET @url = N'http://localhost/Reports/Pages/§§§OBJ§§§.aspx?ItemPath=' ;; WITH RPT AS ( -- Root path SELECT RT.[ItemID] ,RT.[Type] AS [ObjType] ,CONVERT(NVARCHAR(15), N'Folder') AS [ObjTypeName] ,RT.[Path] ,RT.[ModifiedDate] ,USR.[UserName] AS [ModifiedBy] ,CONVERT(NVARCHAR(425), N'') AS [ObjectName] ,CONVERT(NVARCHAR(425), N'/') AS [ParentPath] ,REPLACE(REPLACE(RT.[Path], N'/', N'%2f'), N' ', N'+') AS [ReportLink] FROM dbo.[Catalog] AS RT INNER JOIN dbo.[Users] AS USR ON RT.[ModifiedByID] = USR. [UserID] WHERE RT.[ParentID] IS NULL -- The Root Folder. AND RT.[Type] = 1 UNION ALL SELECT CHILD.[ItemID] ,CHILD.[Type] AS [ObjType] ,CONVERT(NVARCHAR(15), CASE CHILD.[Type] WHEN 1 THEN N'Folder' WHEN 2 THEN N'Report' WHEN 3 THEN N'Resource' WHEN 4 THEN N'Linked Report' WHEN 5 THEN N'DataSource' ELSE N'Report' END) AS [ObjTypeName] ,CHILD.[Path] ,CHILD.[ModifiedDate] ,USR.[UserName] AS [ModifiedBy] ,CHILD.NAME AS [ObjectName] ,CASE WHEN CHILD.[Type] = 1 THEN CHILD.[Path] ELSE RPT.[ParentPath] END AS [ParentPath] ,REPLACE(REPLACE(CHILD.[Path], N'/', N'%2f'), N' ', N'+' ) AS ReportLink FROM dbo.[Catalog] AS CHILD INNER JOIN RPT ON CHILD.[ParentID] = RPT.[ItemID] INNER JOIN dbo.[Users] AS USR ON CHILD.[ModifiedByID] = USR. [UserID] WHERE CHILD.[Type] >= 2 -- All reports and all non empty folders. OR ( CHILD.[Type] = 1 AND EXISTS ( SELECT 1 FROM dbo.[Catalog] AS SUB WHERE SUB.[ParentID] = CHILD.[ItemID] ) ) ) SELECT CASE WHEN RPT.[ObjType] = 1 AND LEN(RPT.[ParentPath]) > 1 THEN SUBSTRING(RPT.[ParentPath], 1, LEN(RPT. [ParentPath]) - LEN(RPT.[ObjectName])) ELSE RPT.[ParentPath] END AS [ObjectPath] ,RPT.[ObjectName] ,RPT.[ObjTypeName] ,RPT.[ModifiedDate] ,RPT.[ModifiedBy] ,REPLACE(@url, N'§§§OBJ§§§', CASE RPT.[ObjType] WHEN 1 THEN N'Folder' WHEN 2 THEN N'Report' WHEN 3 THEN N'Resource' WHEN 5 THEN N'DataSource' ELSE N'Report' END) + RPT.ReportLink + CASE WHEN RPT.[ObjType] = 1 THEN N'&ViewMode=List' ELSE N'' END AS [Link] FROM RPT ORDER BY [ObjectPath] ,RPT.[ObjType] ,RPT.[Path] ,RPT.[ObjectName];
SQL Script Output Screenshot
User Level to execute
- 300
Hope you will like to Overview of all objects created in SSRS ordered by the folder hierarchy.
If you really like reading my blog and understood at least few thing then please don’t forget to subscribe my blog.
If you want daily link and analysis or interesting link go to following website which will give @ your inbox please subscribe our following link resource blog :
For More information related to BI World visit my Mentalist Blog
SQL Server Mentalist >> SQL Learning Blog
Business Intelligence Mentalist >> BI World
Infographic Mentalist >> Image worth explaining thousand Words
Microsoft Mentalist >> MVC,ASP.NET, WCF & LinQ
DBA Mentalist >>Advance SQL Server Blog
Microsoft BI Mentalist >> MS BI Development Update
Connect With me on