Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 20764

SSRS- Create a Job Script to run failed Subscriptions.

$
0
0

Hello,

Is there a way to create SQL Server Agent Job Script to know the failed subscriptions and kickoff all the failed subscriptions?

I have a query that shows all the failed subscriptions for each and every day...

I need to create a SQL Server Agent Job Script that runs every day to re-run the failed subscriptions. 

Here is the Query to show all the Failed Subscriptions. 

SELECT Cat.[Name],
       Own.UserName,
       ISNULL(REPLACE(Sub.[Description], 'send e-mail to ', ''), ' ') AS Recipients, Sub.SubscriptionID,
       Sub.[LastStatus],
       Cat.[Path],
       Sub.[LastRunTime]
FROM dbo.[Subscriptions] Sub WITH (NOLOCK)
    INNER JOIN <g class="gr_ gr_402 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" data-gr-id="402" id="402">dbo</g>.[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] > GETDATE() - 1
ORDER BY Own.UserName;


Thanks, Shyam.


Viewing all articles
Browse latest Browse all 20764

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>