Click here to Skip to main content
Click here to Skip to main content

Reports from Reporting Server

By , 10 May 2013
 

Introduction

Here is some code to list out the reports from the reporting server.

Using the code

We can read and bind reports from the server using the following code:

SET @sql = ';with XMLNAMESPACES (DEFAULT ''http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition'',  
	 ''http://schemas.microsoft.com/SQLServer/reporting/reportdesigner'' AS rd)  
	  SELECT x.value(''@Name'',''VARCHAR(100)'') AS ReportParameterName,  
	  x.value (''DataType[1]'', ''VARCHAR(100)'') AS DataType,  
	  x.value (''AllowBlank[1]'', ''VARCHAR(50)'') AS AllowBlank,  
	  x.value (''Prompt[1]'', ''VARCHAR(100)'') AS Prompt,  
	  x.value (''Hidden[1]'', ''VARCHAR(100)'') AS Hidden,  
	  x.value (''data(DefaultValue/Values/Value)[1]'', ''VARCHAR(100)'') AS Value  
	  FROM (  
		SELECT  PATH  
		  , NAME  
		  , CAST(CAST(content AS VARBINARY(MAX)) AS XML) AS ReportXML   
		FROM '+@strReportServerDB+'.dbo.Catalog   
		WHERE CONTENT IS NOT NULL AND TYPE = 2  
		) A  
		CROSS APPLY ReportXML.nodes(''/Report/ReportParameters/ReportParameter'') R(x)  
		WHERE NAME = '''+ @strReport +''' ORDER BY NAME  
	 '  
	 --print @sql  
	 exec(@sql)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

ShajuAntony
India India
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130513.1 | Last Updated 10 May 2013
Article Copyright 2013 by ShajuAntony
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid