Delete rdl files from SSRS report services
Before deleting report in report server
USE [ReportServer]
GO
--Replace NULL with keywords of the ReportManager's Report Path,
--if reports from any specific path are to be deleted
DECLARE @FilterReportPath AS VARCHAR(500) = NULL
--Replace NULL with the keyword matching the Report File Name,
--if any specific reports are to be deleted
DECLARE @FilterReportName AS VARCHAR(500) = 'List Report'
--Used to prepare the dynamic query
DECLARE @TSQL AS NVARCHAR(MAX)
--Prepare the query to delete the report files.
SET @TSQL = STUFF((SELECT
'; ' +
' ;DELETE ' +
' FROM ' +
' [dbo].[DataSource] ' +
' WHERE ' +
' ItemID = ''' + CONVERT(VARCHAR(MAX), CL.ItemID) + ''''+
' ;DELETE ' +
' FROM ' +
' [dbo].[Catalog] ' +
' WHERE ' +
' ItemID = ''' + CONVERT(VARCHAR(MAX), CL.ItemID) + ''''
FROM
[dbo].[Catalog] CL
WHERE
CL.[Type] = 2 --Report
AND '/' + CL.[Path] + '/' LIKE COALESCE('%/%' + @FilterReportPath + '%/%', '/' + CL.[Path] + '/')
AND CL.Name LIKE COALESCE('%' + @FilterReportName + '%', CL.Name)
FOR XML PATH('')), 1,1,'')
--SELECT @TSQL
--Execute the Dynamic Query
EXEC SP_EXECUTESQL @TSQL
Thank you for your valuable feedback
ReplyDeleteReally good information to show through this blog. I really appreciate you for all the valuable information that you are providing us through your blog.
ReplyDeleteI appreciate the time you spent finding that information
ReplyDeleteThanks for your feedback
DeleteThanks that really help
ReplyDelete