Solved

how can I detect two subscriptions for a report

Posted on 2011-09-02
5
300 Views
Last Modified: 2012-05-12
Hello

How can I detect two subscriptions for a report rs without using the subscription id? Thanks bibi
0
Comment
Question by:bibi92
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
lcohan earned 500 total points
ID: 36475405
I hope the code below will help:


--find_ssrs_subscriptions
select      
            'NextRunDate' = js.next_run_date,
            'NextRunTime' = js.next_run_time,
            'Frequency'   = case when sc.freq_type = 4 then 'Daily'
                                          when sc.freq_type = 8 then 'Weekly'
                                          when sc.freq_type = 16 then 'Monthly'
                                          end,
            'Subscribers' = s.ExtensionSettings,
            'SubscriptionOwner' = us.UserName,
            'LastRun' = s.LastRunTime,
            'ReportPath' = c.Path,
            'SQLJobName' = j.name
from ReportServer.dbo.Subscriptions s
      inner join ReportServer.dbo.Catalog c on c.ItemID = s.Report_OID
      inner join ReportServer.dbo.Users us on us.UserID = s.OwnerId
      inner join msdb.dbo.sysjobs j on j.job_id = (select job_id from msdb.dbo.sysjobsteps where command like '%'+CONVERT(nvarchar(128),s.Report_OID)+'%')
      inner join msdb.dbo.sysjobschedules js on j.job_id=js.job_id
      inner join msdb.dbo.sysschedules sc on js.schedule_id=sc.schedule_id
0
 

Author Comment

by:bibi92
ID: 36482722
Sorry but I don't see the subscription with this query, but with this query :
SELECT s.SubscriptionID
   FROM Catalog c
   INNER JOIN Subscriptions s ON (s.Report_OID = c.ItemID)
   WHERE c.Path = @PATH
Where are the reportserver jobs located?
Thanks
bibi
0
 

Author Comment

by:bibi92
ID: 36501490
DECLARE @PATH           varchar(455)      -- nom du rapport SSRS
DECLARE @ABO             varchar(455)      -- nom de l'abonnement via le champ caché NomAbonnement)
   SELECT @SUBSCRIPTIONID = SubscriptionID FROM (
                  SELECT s.SubscriptionID, (CAST(Parameter as XML).query('
                  for $A in /Parameters/Parameter
                  where $A/Name[.="NAbonnement"]
                  return $A/Values/Value
                  ')).value('.','varchar(128)') as NAbonnement
      FROM Catalog c
      INNER JOIN Subscriptions s ON (s.Report_OID = c.ItemID)
      WHERE c.Path = @PATH) as deriv
      WHERE deriv.NAbonnement = @ABO

Regards

bibi
0
 

Author Closing Comment

by:bibi92
ID: 36501492
I have found a solution. Thanks
0
 
LVL 40

Expert Comment

by:lcohan
ID: 36504637
Sorry I am late with the reply...well here's one other query you may find useful as the SSRS jobs don't have a "friendly name" in msdb if you look via SSMS and this should give you the bame of the report associated with the job - just make sure you run it in SQL server where the SSRS jobs are:



select      distinct
            'ReportName' = c.name,
            'SQLJobName' = j.name
from ReportServer.dbo.Subscriptions s
      inner join ReportServer.dbo.Catalog c on c.ItemID = s.Report_OID
      inner join ReportServer.dbo.Users us on us.UserID = s.OwnerId
      inner join msdb.dbo.sysjobs j on j.job_id = (select job_id from msdb.dbo.sysjobsteps where command like '%'+CONVERT(nvarchar(128),s.Report_OID)+'%')
      inner join msdb.dbo.sysjobschedules js on j.job_id=js.job_id
      inner join msdb.dbo.sysschedules sc on js.schedule_id=sc.schedule_id



0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question