Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How do you delete old one time subscriptions?


How do you delete old one time subscriptions?

Author
Message
mikejone
mikejone
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 372
Am using the following query, to get the subscriptions I want to delete.

SELECT
C.Name
,C.Path
,U.UserName
,S.InactiveFlags
,C.CreationDate
FROM ReportServer.dbo.Subscriptions S
INNER JOIN ReportServer.dbo.Catalog C
ON S.Report_OID = C.ItemID
INNER JOIN ReportServer.dbo.Users U
ON S.OwnerID = U.UserID
WHERE path like '/XXXXXX/%' and CreationDate <'10/01/2013'
ORDER BY LastRunTime DESC

This gives me the list of subscriptions that I want to delete.

Am unsure of the syntax to delete these subscriptions.
Any help is greatly appreciated.

Thanks,
Mike


Mike
mikejone
mikejone
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 372
I replaced the select with a delete, it is not working.
delete
C.Name
,C.Path
,U.UserName
,S.InactiveFlags
,C.CreationDate
FROM ReportServer.dbo.Subscriptions S
INNER JOIN ReportServer.dbo.Catalog C
ON S.Report_OID = C.ItemID
INNER JOIN ReportServer.dbo.Users U
ON S.OwnerID = U.UserID
WHERE path like '/XXXXXX/%' and CreationDate <'10/01/2013'

Any helps appreciated.
Mike


Mike
mikejone
mikejone
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 372
I think i figure it out.
Delete
FROM ReportServer.dbo.Subscriptions
FROM ReportServer.dbo.Subscriptions S
INNER JOIN ReportServer.dbo.Catalog C
ON S.Report_OID = C.ItemID
INNER JOIN ReportServer.dbo.Users U
ON S.OwnerID = U.UserID
WHERE path like '/XXXXXX/%' and CreationDate <'10/01/2013'

If someone has a better solution or suggestion, please reply.
THanks
Mike


Mike
mikejone
mikejone
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 372
Anyone know how to find a one timed subscription?


Mike
Spiff
Spiff
SSC Veteran
SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)

Group: General Forum Members
Points: 294 Visits: 2224
Mike,

Before we start I do not advocate deleting directly from the ReportServer and your posts scared me a little.

Can I ask why you are not using the report manager for this?

If you want to list the run once reports I've amended your SQL above.


SELECT
s.SubscriptionID
, C.Name
,C.Path
,U.UserName
,S.InactiveFlags
,C.CreationDate
, sc.*
FROM dbo.Subscriptions S
INNER JOIN dbo.Catalog C
ON S.Report_OID = C.ItemID
INNER JOIN dbo.Users U
ON S.OwnerID = U.UserID
INNER JOIN ReportSchedule r
ON s.SubscriptionID = r.SubscriptionID
INNER JOIN Schedule sc on r.ScheduleID = sc.ScheduleID
WHERE RecurrenceType = 1
ORDER BY LastRunTime DESC



If you must do it in SQL then to delete the subscriptions use:

exec DeleteSubscription @SubscriptionID = 'GUID-GUID-GUID-GUID'



The trigger on the Subscriptions table removes the SQL Agent job etc.

OK DeleteSubscription is actually just:

DELETE FROM [Subcriptions] WHERE Subscription_ID = @Subscription_ID



but it's usually good practice to use the SP since there may be more it does.
mikejone
mikejone
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 372
From what i recall of the issue, there were couple hundred that needed deleted.
I appreciate your help and your comments.
Thank,
Mike


Mike
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search