<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SSRS &#8211; SQLpowered.com</title>
	<atom:link href="https://sqlpowered.com/script-category/ssrs/feed/" rel="self" type="application/rss+xml" />
	<link>https://sqlpowered.com</link>
	<description>SQL Server + BI</description>
	<lastBuildDate>Thu, 03 Sep 2020 13:33:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://sqlpowered.com/wp-content/uploads/2020/07/FavIcon-e1594067873682-99x100.png</url>
	<title>SSRS &#8211; SQLpowered.com</title>
	<link>https://sqlpowered.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>List of all reports with last execution statistics</title>
		<link>https://sqlpowered.com/script/list-or-reports-with-last-execution-statistics/</link>
		
		<dc:creator><![CDATA[Jan Dvořák]]></dc:creator>
		<pubDate>Thu, 03 Sep 2020 13:28:09 +0000</pubDate>
				<guid isPermaLink="false">https://sqlpowered.com/?post_type=script&#038;p=4627</guid>

					<description><![CDATA[Query to extract the list of all reports from Reporting Services with the last execution details. Tested with SSRS 2019. SELECT [c].[ItemID] [ReportID], [c].[Path] [ReportPath], [c].[Name] [ReportName], [c].[Description], 'http://report_browser_urlp-app.ud4d.com/Reports/report' + REPLACE([c].[Path] , ' ', '%20') [ReportLink], [c].[Property], [c].[Hidden] [IsHidden], [uc].[UserName] [CreatedBy], [c].[CreationDate], [um].[UserName] [ModifiedBy], [c].[ModifiedDate], [c].[MimeType], [c].[SnapshotLimit], [c].[ExecutionFlag], [c].[ExecutionTime],[c].[SubType], [c].[ContentSize],...]]></description>
										<content:encoded><![CDATA[<p>Query to extract the list of all reports from Reporting Services with the last execution details. Tested with SSRS 2019.</p>
<pre class="lang:tsql decode:true ">SELECT 
	[c].[ItemID] [ReportID], [c].[Path] [ReportPath], [c].[Name] [ReportName], [c].[Description],
	'http://report_browser_urlp-app.ud4d.com/Reports/report' + REPLACE([c].[Path] , ' ', '%20') [ReportLink],
	[c].[Property], [c].[Hidden] [IsHidden], 
	[uc].[UserName] [CreatedBy], [c].[CreationDate], 
	[um].[UserName] [ModifiedBy], [c].[ModifiedDate],
	[c].[MimeType],	[c].[SnapshotLimit], 
	[c].[ExecutionFlag], [c].[ExecutionTime],[c].[SubType],	[c].[ContentSize],
	[me].[UserName] [LastExecUser],
	[me].[Parameters] [LastExecParameters],
	[me].[TimeStart] [LastExecTimeStart],
	[me].[TimeEnd] [LastExecTimeEnd],
	[me].[TimeDataRetrieval] [LastExecTimeDataRetrieval],
	[me].[TimeProcessing] [LastExecTimeProcessing],
	[me].[TimeRendering] [LastExecTimeRendering],
	[me].[TotalDuration] [LastExecTotalDuration]
FROM [ReportServer].[dbo].[Catalog] [c] 
	LEFT JOIN [ReportServer].[dbo].[Users] [uc] ON [c].[CreatedByID] = [uc].[UserID]
	LEFT JOIN [ReportServer].[dbo].[Users] [um] ON [c].[ModifiedByID] = [um].[UserID]
	LEFT JOIN (SELECT [el].[ReportID], [UserName], [el].[Parameters], [el].[TimeStart], [el].[TimeEnd],
					  [el].[TimeDataRetrieval], [el].[TimeProcessing], [el].[TimeRendering],
					  DATEDIFF(ms, [el].[TimeStart], [el].[TimeEnd]) [TotalDuration]
			   FROM [ReportServer].[dbo].[ExecutionLogStorage] [el]
			   WHERE [el].[LogEntryId] IN (	select MAX([el].[LogEntryId]) [LogEntryID]
											FROM [ReportServer].[dbo].[ExecutionLogStorage] [el]
												INNER JOIN [ReportServer].[dbo].[Catalog] [c] ON [c].[ItemID] = [el].[ReportID]
											GROUP BY [el].[ReportID])
	) [me] ON [me].[ReportID] = [c].[ItemID]
WHERE [c].[Type] = 2</pre>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>View report parameters details</title>
		<link>https://sqlpowered.com/script/4626/</link>
		
		<dc:creator><![CDATA[Jan Dvořák]]></dc:creator>
		<pubDate>Sun, 30 Aug 2020 20:45:14 +0000</pubDate>
				<guid isPermaLink="false">https://sqlpowered.com/?post_type=script&#038;p=4626</guid>

					<description><![CDATA[Script to view all parameters in all reports found in the Reporting Services reports catalog table. ;WITH [params] AS ( SELECT [r].[ReportPath], [r].[ReportName], [p].[Param].[value]('Name[1]', 'nvarchar(500)') AS [ParameterName], [p].[Param].[value]('Type[1]', 'nvarchar(500)') AS [Type], [p].[Param].[value]('Nullable[1]', 'varchar(10)') AS [Nullable], [p].[Param].[value]('AllowBlank[1]', 'varchar(10)') AS [AllowBlank], [p].[Param].[value]('MultiValue[1]', 'varchar(10)') AS [MultiValue], [p].[Param].[value]('UsedInQuery[1]', 'varchar(10)') AS [UsedInQuery], [p].[Param].[value]('State[1]', 'varchar(100)') AS...]]></description>
										<content:encoded><![CDATA[<p>Script to view all parameters in all reports found in the Reporting Services reports catalog table.</p>
<pre class="lang:tsql decode:true">;WITH [params] AS 
(
	SELECT 
		[r].[ReportPath], [r].[ReportName],
		[p].[Param].[value]('Name[1]', 'nvarchar(500)') AS [ParameterName], 
		[p].[Param].[value]('Type[1]', 'nvarchar(500)') AS [Type], 
		[p].[Param].[value]('Nullable[1]', 'varchar(10)') AS [Nullable], 
		[p].[Param].[value]('AllowBlank[1]', 'varchar(10)') AS [AllowBlank],
		[p].[Param].[value]('MultiValue[1]', 'varchar(10)') AS [MultiValue], 
		[p].[Param].[value]('UsedInQuery[1]', 'varchar(10)') AS [UsedInQuery], 
		[p].[Param].[value]('State[1]', 'varchar(100)') AS [State], 
		[p].[Param].[value]('PromptUser[1]', 'varchar(10)') AS [PromptUser], 
		[p].[Param].[value]('DynamicPrompt[1]', 'varchar(10)') AS [DynamicPrompt],
		[p].[Param].[value]('Prompt[1]', 'varchar(100)') AS [Prompt],
		[p].[Param].[value]('DynamicValidValues[1]', 'varchar(10)') AS [DynamicValidValues],
		[p].[Param].[value]('DynamicDefaultValue[1]', 'varchar(10)') AS [DynamicDefaultValue],
		[p].[Param].[exist]('Dependencies[1]/Dependency') AS [HasDependencies],
		[p].[Param].[exist]('DefaultValues[1]/Value') AS [HasDefaultValues],
		[p].[Param].[exist]('Values[1]/Value') AS [HasValues],
		[p].[Param].[value]('Dependencies[1]', 'nvarchar(4000)') AS [Dependencies],
		[p].[Param].[value]('DefaultValues[1]', 'nvarchar(4000)') AS [DefaultValues],
		[p].[Param].[value]('Values[1]', 'nvarchar(4000)') AS [Values]
     FROM (SELECT 
				[c].[Path] [ReportPath], [c].[Name] [ReportName], 
				CONVERT(XML, [c].[Parameter]) AS [ParamsXML] 
		   FROM [dbo].[Catalog] [c]
           WHERE [c].[Type] = 2
         ) [r] 
     CROSS APPLY [r].[ParamsXML].[nodes]('/Parameters/Parameter') AS [p]([Param]) 
    ) 
SELECT 
	[ReportPath], [ReportName],
	[ParameterName], [Type], [Nullable], [AllowBlank], [MultiValue],
	[UsedInQuery], [State],
	[PromptUser], [DynamicPrompt], [Prompt],
	[DynamicValidValues], [DynamicDefaultValue],
	[HasDependencies], [HasDefaultValues], [HasValues],
	[Dependencies], [DefaultValues], [Values] 
FROM [params] 
ORDER BY [params].[ReportPath]</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Reports execution history</title>
		<link>https://sqlpowered.com/script/reports-execution-history/</link>
		
		<dc:creator><![CDATA[Jan Dvořák]]></dc:creator>
		<pubDate>Tue, 26 Nov 2019 10:20:17 +0000</pubDate>
				<guid isPermaLink="false">https://sqlpowered.com/?post_type=script&#038;p=3436</guid>

					<description><![CDATA[Run this script against ReportServer database to obtain basic historical overview of reports execution. Remember that default log history retention is 60 days. SELECT [EL].[LogEntryId], [EL].[InstanceName], [C].[Path], [C].[Name] [ReportName], [EL].[UserName], CASE([EL].[ReportAction]) WHEN 1 THEN 'Render' WHEN 2 THEN 'BookmarkNavigation' WHEN 3 THEN 'DocumentMapNavigation' WHEN 4 THEN 'DrillThrough' WHEN 5 THEN...]]></description>
										<content:encoded><![CDATA[<p>Run this script against ReportServer database to obtain basic historical overview of reports execution. Remember that default log history retention is <a href="https://docs.microsoft.com/en-us/sql/reporting-services/report-server/report-server-executionlog-and-the-executionlog3-view?view=sql-server-ver15" target="_blank" rel="noopener noreferrer">60 days</a>.</p>
<pre class="lang:tsql decode:true ">SELECT
	[EL].[LogEntryId],
	[EL].[InstanceName],
	[C].[Path],
	[C].[Name] [ReportName],
	[EL].[UserName],
	CASE([EL].[ReportAction])
		WHEN 1 THEN 'Render'
		WHEN 2 THEN 'BookmarkNavigation'
		WHEN 3 THEN 'DocumentMapNavigation'
		WHEN 4 THEN 'DrillThrough'
		WHEN 5 THEN 'FindString'
		WHEN 6 THEN 'GetDocumentMap'
		WHEN 7 THEN 'Toggle'
		WHEN 8 THEN 'Sort'
		WHEN 9 THEN 'Execute'
		ELSE 'Unknown'
	END [ItemAction],
	[EL].[TimeStart], YEAR([EL].[TimeStart]) [Start_Year], MONTH([EL].[TimeStart]) [Start_Month],
	DATENAME(MONTH,[EL].[TimeStart]) [Start_Month_Name], DATENAME(DW,[EL].[TimeStart]) [Start_Day_Of_Week], 
	DATEPART(WEEKDAY,[EL].[TimeStart]) [Start_Day_Number_of_Week],
	[EL].[TimeEnd], [EL].[TimeDataRetrieval], [EL].[TimeProcessing], [EL].[TimeRendering],
	CASE([EL].[Source])		
		WHEN 1 THEN 'Live'
		WHEN 2 THEN 'Cache'
		WHEN 3 THEN 'Snapshot' 
		WHEN 4 THEN 'History' 
		WHEN 5 THEN 'AdHoc'
		WHEN 6 THEN 'Session'
		WHEN 7 THEN 'Rdce'
		ELSE 'Unknown'
	END [Source],
	[EL].[Status],
	[EL].[ByteCount],[EL].[RowCount],
	[EL].[Parameters], [C].[Description],
	[CBY].[UserName] [CreatedBy], [C].[CreationDate],
	[MBY].[UserName] [ModifiedBy], [C].[ModifiedDate]
FROM [dbo].[ExecutionLogStorage] [EL]
	LEFT JOIN [dbo].[Catalog] [C] ON [EL].[ReportID] = [C].[ItemID]
	LEFT JOIN [dbo].[Users] [CBY] ON [C].[CreatedByID] = [CBY].[UserID]
	LEFT JOIN [dbo].[Users] [MBY] ON [C].[ModifiedByID] = [MBY].[UserID]
WHERE [EL].[Source] = 1 AND [C].[Type] = 2
ORDER BY c.[Path], c.[Name]
GO</pre>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>List all data sources with connection string detail</title>
		<link>https://sqlpowered.com/script/list-all-data-sources-with-connection-string-detail/</link>
		
		<dc:creator><![CDATA[Jan Dvořák]]></dc:creator>
		<pubDate>Tue, 02 Apr 2019 11:50:26 +0000</pubDate>
				<guid isPermaLink="false">https://sqlpowered.com/?post_type=script&#038;p=3081</guid>

					<description><![CDATA[Following query is handful in case of migrating reports to different Report Server or when shared data sources should be changed, renamed or deleted.  Query takes some time to be executed because of XML parsing. WITH [XmlData] AS ( SELECT [ItemID], [Name], [Type], [Xml] = TRY_CONVERT(XML, CONVERT(VARBINARY(MAX), [Content])) FROM [dbo].[Catalog]...]]></description>
										<content:encoded><![CDATA[<p>Following query is handful in case of migrating reports to different Report Server or when shared data sources should be changed, renamed or deleted.  Query takes some time to be executed because of XML parsing.</p>
<pre class="lang:tsql decode:true ">WITH [XmlData] AS (
    SELECT [ItemID], [Name], [Type],
         [Xml] = TRY_CONVERT(XML, CONVERT(VARBINARY(MAX), [Content]))
    FROM [dbo].[Catalog]
),
[SharedDS] AS 
(
    SELECT 
		[ds].[ItemID], [c].[Name] [SharedDS], [ds].[Name] [LocalDS],
		[Xml].[value]('(/*:DataSourceDefinition/*:Extension)[1]', 'NVARCHAR(260)') [DataProvider],
        [Xml].[value]('(/*:DataSourceDefinition/*:ConnectString)[1]', 'NVARCHAR(MAX)') [ConnString]
    FROM [dbo].[DataSource] [ds]
        INNER JOIN [XmlData] [c] ON [ds].[Link] = [c].[ItemID]
),
[DS] AS 
(
    SELECT
        [r].[ItemID], [sds].[SharedDS], [r].[LocalDS], 
        CAST ((CASE WHEN [sds].[SharedDS] IS NOT NULL THEN 1 ELSE 0 END) AS BIT) [IsSharedDS],
		ISNULL([r].[DataProvider], [sds].[DataProvider]) [DataProvider],
		ISNULL([r].[ConnString], [sds].[ConnString]) [ConnString]
    FROM ( SELECT [c].[ItemID],
               [DataSourceXml].[value]('@Name', 'NVARCHAR(260)') [LocalDS],
               [DataSourceXml].[value]('(*:ConnectionProperties/*:DataProvider)[1]', 'NVARCHAR(260)') [DataProvider],
               [DataSourceXml].[value]('(*:ConnectionProperties/*:ConnectString)[1]', 'NVARCHAR(MAX)') [ConnString]
            FROM [XmlData] [c]
                CROSS APPLY [Xml].[nodes]('/*:Report/*:DataSources/*:DataSource') [DataSource]([DataSourceXml])
            WHERE [c].[Type] = 2
        ) [r]
        LEFT JOIN [SharedDS] [sds] ON [r].[ItemID] = [sds].[ItemID] AND [r].[LocalDS] = [sds].[LocalDS]
),
[Main] AS 
(
    SELECT [ItemID],
        [QueryXml].[value]('@Name', 'NVARCHAR(256)') [DataSet],
        [QueryXml].[value]('(*:Query/*:DataSourceName)[1]', 'NVARCHAR(260)') [DataSource],
        [QueryXml].[value]('(*:Query/*:CommandType)[1]', 'NVARCHAR(15)') [CommandType],
        [QueryXml].[value]('(*:Query/*:CommandText)[1]', 'NVARCHAR(MAX)') [CommandText]
    FROM [XmlData]
        CROSS APPLY [Xml].[nodes]('/*:Report/*:DataSets/*:DataSet') [QueryData]([QueryXml])
)
SELECT 
    [c].[Path] [ReportPath], [c].[Name] [ReportName], [ds].[LocalDS], [ds].[SharedDS], [ds].[IsSharedDS],
    [ds].[DataProvider], [ds].[ConnString], [m].[DataSet], ISNULL([m].[CommandType], 'Text') [CommandType], [m].[CommandText]
FROM [Main] [m]
    INNER JOIN [DS] [ds] ON [ds].[ItemID] = [m].[ItemID] AND [m].[DataSource] = [ds].[LocalDS]
    INNER JOIN [dbo].[Catalog] [c] ON [ds].[ItemID] = [c].[ItemID]
ORDER BY [ReportPath], [ReportName]
GO</pre>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
