<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Report to extract failed subscriptions in Report Server</title>
    <link>https://community.fabric.microsoft.com/t5/Report-Server/Report-to-extract-failed-subscriptions/m-p/2790241#M25973</link>
    <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We develoepd multiple paginated reports and created subscriptions in Power Bi Report server.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please assist the logic to extract failed subsctiptions list from audit DB or audit logs. We want to build report to extract the failed subscriptions it helps team to start investigate the issues immediatly&amp;nbsp; and fix the issues.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 23 Sep 2022 16:08:56 GMT</pubDate>
    <dc:creator>kreddy1</dc:creator>
    <dc:date>2022-09-23T16:08:56Z</dc:date>
    <item>
      <title>Report to extract failed subscriptions</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Report-to-extract-failed-subscriptions/m-p/2790241#M25973</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We develoepd multiple paginated reports and created subscriptions in Power Bi Report server.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please assist the logic to extract failed subsctiptions list from audit DB or audit logs. We want to build report to extract the failed subscriptions it helps team to start investigate the issues immediatly&amp;nbsp; and fix the issues.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 16:08:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Report-to-extract-failed-subscriptions/m-p/2790241#M25973</guid>
      <dc:creator>kreddy1</dc:creator>
      <dc:date>2022-09-23T16:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: Report to extract failed subscriptions</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Report-to-extract-failed-subscriptions/m-p/2790486#M25975</link>
      <description>&lt;P&gt;You can query the SSRS catalog to get the information you need.&lt;/P&gt;&lt;P&gt;Here is a good article with queries, etc. - &lt;A href="https://www.sqlshack.com/ssrs-failed-subscription-alerting/" target="_blank"&gt;https://www.sqlshack.com/ssrs-failed-subscription-alerting/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;And below is the code from the same source.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;USE ReportServer
GO
 
DECLARE @count INT
 
SELECT
   	Cat.[Name],
   	Rep.[ScheduleId],
   	Own.UserName,
   	ISNULL(REPLACE(Sub.[Description],'send e-mail to ',''),' ') AS Recipients,
   	Sub.[LastStatus],
   	Cat.[Path],
   	Sub.[LastRunTime]
INTO
   	#tFailedSubs
FROM
   	dbo.[Subscriptions] Sub with (NOLOCK)
INNER JOIN
   	dbo.[Catalog] Cat with (NOLOCK) on Sub.[Report_OID] = Cat.[ItemID]
INNER JOIN
   	dbo.[ReportSchedule] Rep with (NOLOCK) ON (cat.[ItemID] = Rep.[ReportID] and Sub.[SubscriptionID] =Rep.[SubscriptionID])
INNER JOIN
   	dbo.[Users] Own with (NOLOCK) on Sub.[OwnerID] = Own.[UserID]
WHERE
Sub.[LastStatus] NOT LIKE '%was written%' --File Share subscription
AND Sub.[LastStatus] NOT LIKE '%pending%' --Subscription in progress. No result yet
AND Sub.[LastStatus] NOT LIKE '%mail sent%' --Mail sent successfully.
AND Sub.[LastStatus] NOT LIKE '%New Subscription%' --New Sub. Not been executed yet
AND Sub.[LastStatus] NOT LIKE '%been saved%' --File Share subscription
AND Sub.[LastStatus] NOT LIKE '% 0 errors.' --Data Driven subscription
AND Sub.[LastStatus] NOT LIKE '%succeeded%' --Success! Used in cache refreshes
AND Sub.[LastStatus] NOT LIKE '%successfully saved%' --File Share subscription
AND Sub.[LastStatus] NOT LIKE '%New Cache%' --New cache refresh plan
-- AND Sub.[LastRunTime] &amp;gt; GETDATE()-1
 
-- If any failed subscriptions found, proceed to build HTML &amp;amp; send mail.
SELECT @count = COUNT(*) FROM #tFailedSubs
 
IF (@count&amp;gt;0)
 
   	BEGIN
 
   	DECLARE @EmailRecipient NVARCHAR(1000)
   	DECLARE @SubjectText NVARCHAR(1000)
   	DECLARE @ProfileName NVARCHAR(1000)
   	DECLARE @tableHTML1 NVARCHAR(MAX)
   	DECLARE @tableHTMLAll NVARCHAR(MAX)
 
   	SET NOCOUNT ON
   	
   	SELECT @EmailRecipient = 'Changeme@craigporteous.com'
   	SET @SubjectText = 'Failed SSRS Subscriptions'
 
   	--Set DB Mail profile to use
   	SELECT TOP 1 @ProfileName = [Name] FROM msdb.dbo.sysmail_profile WHERE [Name] = 'Alert-BI-Admins'
   	
   	SET @tableHTML1 =
 
         	N'&amp;lt;H3 style="color:red; font-family:verdana"&amp;gt;Failed SSRS Subscription details. Please resolve &amp;amp; re-run jobs&amp;lt;/H3&amp;gt;' +
         	N'&amp;lt;p align="left" style="font-family:verdana; font-size:8pt"&amp;gt;&amp;lt;/p&amp;gt;' +
         	N'&amp;lt;table border="2" style="font-size:8pt; font-family:verdana; text-align:left"&amp;gt;' +
         	N'&amp;lt;tr style="color:black; font-weight:bold"&amp;gt;' +
         	N'&amp;lt;th&amp;gt;Report Name&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;SQL Agent Job ID&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Owner Username&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Distribution&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Error Message&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Report Location&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Last Run Time&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;' +
         	CAST((
                	SELECT
                       	td = t.[Name],'',
                       	td = t.[ScheduleId],'',
                       	td = t.[UserName],'',
                       	td = t.[Recipients],'',
                       	td = t.[LastStatus],'',
                       	td = t.[Path],'',
                	   	td = t.[LastRunTime]
                	FROM
                       	#tFailedSubs t
                	FOR XML PATH('tr'), TYPE)
         	AS NVARCHAR(MAX) ) +
         	N'&amp;lt;/table&amp;gt;'
 
SET @tableHTMLAll = ISNULL(@tableHTML1,'')
 
IF @tableHTMLAll &amp;lt;&amp;gt; ''
   	
   	BEGIN
 
   	--SELECT @tableHTMLAll
         	EXEC msdb.dbo.sp_send_dbmail
                	@profile_name = @ProfileName,
                	@recipients = @EmailRecipient,
                	@body = @tableHTMLAll,
                	@body_format = 'HTML',
                	@subject = @SubjectText
   	END
 
SET NOCOUNT OFF
 
DROP TABLE #tFailedSubs
 
END  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 19:04:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Report-to-extract-failed-subscriptions/m-p/2790486#M25975</guid>
      <dc:creator>Shahfaisal</dc:creator>
      <dc:date>2022-09-23T19:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Report to extract failed subscriptions</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Report-to-extract-failed-subscriptions/m-p/4271992#M38508</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;we have developed a paginated report that has a suscription baded on data. this way sends an emial to the owners tha has a suscription with an error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the query that the paginated report uses:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SELECT convert(varchar(50), sus.[SubscriptionID]) as SubscriptionID
     , sus.[Description]
      , sus.[LastStatus]
      , sus.LastRunTime
      , cata.[Path]
      , cata.[Name]
      , usucrea.UserName as usuario_creador
	  , usumod.UserName as usuario_modif
	  , RTRIM(corpuser.email) as email_usu_modif
	  , RTRIM(corpuser.full_name) as nombre_usu_modif
      , getdate() as fhasta
      , getdate() - 1 as fdesde
FROM [PBIReportServer].[dbo].[Subscriptions] sus WITH(NOLOCK)
    left join [PBIReportServer].[dbo].[Catalog] cata WITH(NOLOCK) on sus.Report_OID = cata.ItemID
    left join [PBIReportServer].[dbo].[Users] usucrea WITH(NOLOCK) on cata.[CreatedByID] = usucrea.UserID
    left join [PBIReportServer].[dbo].[Users] usumod WITH(NOLOCK) on cata.[ModifiedByID] = usumod.UserID
    left join [PBIReportServer].[dbo].[my_table_of_corp_users] corpuser WITH(NOLOCK) on usumod.UserName = corpuser.ID
where sus.EventType = 'TimedSubscription'
    and (
        (sus.LastStatus like 'Done:%' and sus.LastStatus not like '%0 errors%' )
    or sus.LastStatus like 'Failure%' 
      )
    and getdate()-1 &amp;lt;= sus.LastRunTime and sus.LastRunTime &amp;lt;= GETDATE()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;my_table_of_corp_users&lt;/FONT&gt; is a table where we tansfer every day name, ID and email of the corporate users.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 06:48:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Report-to-extract-failed-subscriptions/m-p/4271992#M38508</guid>
      <dc:creator>vcarazo</dc:creator>
      <dc:date>2024-11-06T06:48:32Z</dc:date>
    </item>
  </channel>
</rss>

