Extracting Report Content from the SSRS Catalog

Overview

This article provides code to extract details of report definitions on an SSRS server.

Code

Run this against the "ReportServer" database on the SSRS server

drop table if exists #Reports

select 
     Path
    ,RdlContent = convert(xml, substring(convert(varchar(max), convert(varbinary(max), content)),44,10000000))
into
    #Reports
from 
    catalog 
where 
    Type = 2



;with xmlnamespaces(
    default 'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition'
    ,'http://schemas.microsoft.com/SQLServer/reporting/reportdesigner' as rd
    ,'http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition' as cl
    ,'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily' as df
)
select
    Report = r.Path
    ,DataSetName = T.c.value('@Name', 'varchar(1000)')
    ,SP = T.c.value('Query[1]/CommandText[1]', 'varchar(8000)')
from
    #Reports r
    cross apply r.RdlContent.nodes('/Report/DataSets/DataSet') as T(c)