Tuesday, 13 November 2018

How to find user roles on different Catalog|Folder|Report in SSRS

How to find user roles on different Catalog|Folder|Report in SSRS The below query will give you, the user roles on different catalogs

USE ReportServer
GO
SELECT
    CASE
        WHEN [Catalog].[Type]=1 THEN 'Folder'
        WHEN [Catalog].[Type]=2 THEN 'Report'
        WHEN [Catalog].[Type]=3 THEN 'Resource'
        WHEN [Catalog].[Type]=4 THEN 'Linked Report'
        WHEN [Catalog].[Type]=5 THEN 'Data Source'
        WHEN [Catalog].[Type]=6 THEN 'Report Model'
        WHEN [Catalog].[Type]=8 THEN 'Shared Dataset'
        WHEN [Catalog].[Type]=9 THEN 'Report Part'     
    END AS CatalogType
    ,[Catalog].Name CatalogName
    , Roles.RoleName Role
    , Users.UserName UserId
FROM PolicyUserRole
INNER JOIN Roles ON PolicyUserRole.RoleID = Roles.RoleID
INNER JOIN Policies ON PolicyUserRole.PolicyID = Policies.PolicyID
INNER JOIN Users ON PolicyUserRole.UserID = Users.UserID
INNER JOIN [Catalog] ON PolicyUserRole.PolicyID = [Catalog].PolicyID

Order by Users.UserName

Monday, 9 April 2018

How to get SSRS Report Subscription, Share Schedule, Last run date & Status

These are the tables that are relevant for pulling out the subscription information:
  • dbo.Catalog - Information about the deployed reports
  • dbo.ReportSchedule - Information relating reports to schedules and schedules
  • dbo.Subscriptions - Information about the subscriptions
  • dbo.Schedule - Information about the schedules
The SQL below pulls out schedule interval information for all reports. It doesn't calculate the next run dates but by figuring out the interval that the schedule is supposed to run on you can write another query to generate the actual dates.
This SQL was originally written for a report that just displays a string describing the interval so the final output is probably not what you're after. It should give you a good starting point though since it does figure out all of the interval details.

USE REPORTSERVER
GO
SELECT C.NAME AS Report_Name ,S.Description AS Subscription_Name ,SCH.NAME Share_Schedule,S.LastRunTime Subscription_LastRunTime,S.LastStatus 
FROM [dbo].[Schedule] SCH 
INNER JOIN [dbo].[ReportSchedule] RS ON RS.ScheduleID=SCH.ScheduleID
LEFT JOIN [dbo].[Subscriptions] S ON S.SubscriptionID=RS.SubscriptionID
LEFT JOIN [Catalog] C ON C.ItemID=RS.REportID