Thursday, July 21, 2011

Count of Sub_reports from Main_report

How to calculate the count of Sub_reports from Main_report?

I have a Main_report it contains the many sub_reports like Employee, Product, Sales, Finance.
In my report I have return the count of sub_reports in my Main_reports. so what I did was I have used to xml.

DECLARE @xml XML

SELECT @xml = BulkColumn

FROM OPENROWSET(BULK 'E:\WORK AREA\SSRS\SSRSPractice\SSRSPractice\MainReport.rdl', SINGLE_BLOB) AS x
DECLARE @charxml VARCHAR(MAX)

SELECT @charxml=CAST(@xml AS VARCHAR(MAX))

SELECT LEN(REPLACE(@charxml,'','a'))-LEN(@charxml) AS CountofReports