Solved

how can I detect two subscriptions for a report

Posted on 2011-09-02
5
272 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
  • 3
  • 2
5 Comments
 
LVL 39

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 39

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Installing SQL Server Express Management Studio 4 23
Update in Sql 7 30
Safely Uninstall SQL Server 2008 R2 Express 3 60
Upgrading SQL Server Management Tools 7 36
Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now