Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Welcome to my blog. I work as Database lead at Synaptic Digital. Hope you find some interesting stuff here.
Browse by Tags · View All
BRH 17
SQL Server 15
#SQL Server 11
#BI 10
#TSQL 8
TSQL 8
BI 7
SSRS 6
#SQLServer 6
SSRS 2008R2 5

Archive · View All
January 2011 6
December 2010 5
September 2012 4
May 2012 4
March 2011 4
November 2012 2
October 2012 2
January 2012 2
February 2011 2
November 2010 2

Retrieve Report Definitions from ReportServer Database

Nov 26 2010 8:24PM by Chintak Chhapia   

I want to send some report definitions to team sitting somewhere else. I don’t have report project as connection to TFS can’t be made from here.  The machine, I have is development environment server where everybody creates reports for learning and demo.

So, One way of doing this to save report one by one from report manager.

The other way of doing this is to use the RS scripter tool. This is great tool, but there is no option to export reports created by specific user.  More details for this is available at http://www.sqldbatips.com/showarticle.asp?ID=62

Another way of doing this is, we can extract information from catalog table reportserver database. I tried but it seems the report definition is stored inside the IMAGE column. IMAGE datatype is deprecated feature, but internally this is being used. For more details on deprecated features can be found here http://technet.microsoft.com/en-us/library/bb510662.aspx

SELECT  ReportPath = c.path
       ,ReportName =  c.name
       ,ReportDefination = CONVERT(XML,CONVERT(VARBINARY(MAX),c.content)) 
FROM dbo.catalog c
WHERE c.type = 2

We can use BCP for expoting data to files

USE ReportServer
GO
--Create a global teble vaiable 
IF OBJECT_ID('tempdb..##reportDetail') IS NOT NULL
	DROP TABLE tempdb..##reportDetail
GO
CREATE TABLE ##reportDetail  
(
ReportName VARCHAR(850),
ReportDefination XML,
RowNumber INT
)

DECLARE @i INT =0;
DECLARE @folderName VARCHAR(MAX) = 'c:\tempreports\';
DECLARE @filename VARCHAR(854) = '';
DECLARE @bcpCommand VARCHAR(8000)  = '';

--suppose we need to extarct all the data from AdventureWork2008SampleReports folder
DECLARE @username varchar(850) = '--- -\chinak';

--Seftynet if somebody doesn't add backshash 
SELECT @folderName = CASE WHEN RIGHT(@folderName,1) = '\' THEN @folderName ELSE @folderName + '\' END;

--Catalog contains all objects on reportserver like folder,datasource,model,report Type. For report defination type is 2.
INSERT INTO ##reportDetail  
(
ReportName,
ReportDefination,
RowNumber 
)
SELECT  ReportName =  c.name
       ,ReportDefination = CONVERT(XML,CONVERT(VARBINARY(MAX),c.content)) 
       ,RowNumber = ROW_NUMBER() OVER (ORDER BY c.itemid)
FROM dbo.catalog c
INNER JOIN dbo.users u ON c.CreatedByID = u.UserID
WHERE c.type = 2
AND u.UserName LIKE @username

SELECT @i = MAX(RowNumber) FROM ##reportDetail
WHILE (@i > 0)
BEGIN
	 SELECT @filename = @folderName + reportname + '.RDL'	 FROM ##reportDetail WHERE  RowNumber = @i
	 SELECT @bcpCommand = 'bcp "SELECT ReportDefination FROM ##reportDetail WHERE RowNumber =' + STR(@i) + ' " queryout "' 
	 SELECT @bcpCommand = @bcpCommand + @FileName + '" -T'
	 EXEC xp_cmdshell @bcpCommand
	 SELECT @i -= 1
END 
GO

--Drop temp table
IF OBJECT_ID('tempdb..##reportDetail') IS NOT NULL
	DROP TABLE tempdb..##reportDetail
GO

Note:- For this script to work, XP_CMDSHELL should be enabled. Please do not enable XP_CMDSHELL on production environmnets as this possesses a security risk. In alternate to this, we can also use SSIS for each loop to export report definition.

After completing this, I realized one more sophisticated way of downloading definitions from report server and its using the GetItemDefinition method. But, I still have to check weather by this meathod, i get all report’s uploaded by a particular person.

Tags: BRH, ReportServer, Catalog, TSQL, SQL Server, #SQLServer,


Chintak Chhapia
40 · 5% · 1457
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]