h1

SQL SERVER How to Get Stored Procedure Names used by Reports, SQL Reporting Services

02/21/2009

We are using SQL Reporting Services for Reports.

Today we need to identify Stored Procedures used by Reports, so we want to transfer those SPs to Replication server.
I found very good query on Jacob Sebastian Blog.

;WITH xmlnamespaces (
    default
    'http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition',
    'http://schemas.microsoft.com/SQLServer/reporting/reportdesigner' AS rd
)
SELECT
    NAME AS reportname,
    q.value('@Name[1]', 'VARCHAR(50)') AS datasetname,
    x.value('DataSourceName[1]', 'VARCHAR(50)') AS datasourcename,
    x.value('CommandText[1]', 'VARCHAR(50)') AS spname
FROM
(
    SELECT NAME,
    CAST(CAST(content AS varbinary(MAX)) AS xml) AS reportxml
    FROM reportserver.dbo.catalog
) a
CROSS apply reportxml.nodes('/Report/DataSets/DataSet') d(q)
CROSS apply q.nodes('Query') r(x)
Advertisements

2 comments

  1. This was very helpful, thanks!


  2. This does not seem to pull all reports, it works, but seems to be a partial list. Also required an add of
    WHERE NOT patindex(‘%.%’, name) > 0
    to the Select, to keep it from getting an error.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: