{"id":310,"date":"2013-10-04T17:50:00","date_gmt":"2013-10-04T11:50:00","guid":{"rendered":"http:\/\/markwheeler.com\/wordpress\/?p=310"},"modified":"2013-10-04T17:50:00","modified_gmt":"2013-10-04T11:50:00","slug":"manage-all-ssrs-subscriptions-in-sharepoint","status":"publish","type":"post","link":"https:\/\/www.markwheeler.com\/?p=310","title":{"rendered":"Manage all SSRS Subscriptions in Sharepoint"},"content":{"rendered":"<p>I needed a way for me and my teammates to see and edit all report subscriptions across a Sharepoint site<br \/>\nwith SQL Reporting Services in Integrated mode.<\/p>\n<p>There are two parts here; the first is a function that returns text between delimiters. This is important to get<br \/>\nthe site and folder from the ItemPath in the ReportServer&#8217;s Catalog table.<\/p>\n<p>This function takes a string, delimiter and position. For example<br \/>\ndbo.fn_ParseStr(&#8216;Server\/SubSite\/Folder&#8217;,&#8217;\/&#8217;,2)<br \/>\nWill Return the SubSite as this is the 2nd item delimited.<\/p>\n<p>dbo.fn_ParseStr(&#8216;Server\/SubSite\/Folder&#8217;,&#8217;\/&#8217;,3)<br \/>\nWill Return the Folder as it is the 3rd item delimited.<\/p>\n<p><code>create Function dbo.fn_ParseStr(@Message Varchar(1000), @delimiter char(1), @index int )<br \/>\nReturns Varchar(1000)<br \/>\nAs<br \/>\nBegin<br \/>\nDeclare<br \/>\n@curIndex int = 0,<br \/>\n@pos int = 1,<br \/>\n@prevPos int = 0,<br \/>\n@result varchar(1000)<br \/>\nwhile @pos &gt; 0<br \/>\nBegin<br \/>\nset @pos = CHARINDEX(@delimiter, @Message, @prevPos);<br \/>\nif(@pos &gt; 0)<br \/>\nbegin-- get the chars between the prev position to next delimiter pos<br \/>\nset @result = SUBSTRING(@message, @prevPos, @pos-@prevPos)<br \/>\nend<br \/>\nelse<br \/>\nbegin--get last delim message<br \/>\nset @result = SUBSTRING(@message, @prevPos, LEN(@message))<br \/>\nend<br \/>\nif(@index = @curIndex)<br \/>\nbegin<br \/>\nreturn @result<br \/>\nend<br \/>\nset @prevPos = @pos + 1<br \/>\nset @curIndex = @curIndex + 1;<br \/>\nend<br \/>\nreturn ''--not found<br \/>\nEnd<br \/>\n<\/code><br \/>\nHere is the query to return the fields for the report and also builds the link to edit the subscription.<br \/>\n<code><br \/>\nUSE [ReportServer]<br \/>\nGO<br \/>\nSELECT<br \/>\ndistinct(S.[SubscriptionID]),<br \/>\nS.[ModifiedDate],<br \/>\nS.[Description],<br \/>\nS.[LastStatus],<br \/>\nS.[LastRunTime],<br \/>\nC.ItemID as CatalogID,<br \/>\n--- This substring removes the GUID from the Path in the Catalog table.<br \/>\nsubstring(C.[Path], 40, 255) as Path ,<br \/>\ndbo.fn_ParseStr(C.[Path],'\/',2) as Site,<br \/>\ndbo.fn_ParseStr(C.[Path],'\/',3) as Folder,<br \/>\nC.[Name],<br \/>\n[U1].[UserName] AS [Owner],<br \/>\n[URL2] = 'https:\/\/yourservername\/'+ dbo.fn_ParseStr(C.[Path],'\/',2) +<br \/>\n'\/_layouts\/ReportServer\/SPSubscriptionProperties.aspx?SubscriptionID=' + CAST(S.[SubscriptionID] AS VARCHAR(80)) +<br \/>\n'&amp;list=' + CAST(F.[tp_ID] AS VARCHAR(80)) + '&amp;ID=' + CAST(D.[DoclibRowId] AS VARCHAR(80))<br \/>\nFROM<br \/>\nReportServer.dbo.[Subscriptions] S<br \/>\nJOIN ReportServer.dbo.[Catalog] C ON S.[Report_OID] = C.[ItemID]<br \/>\nJOIN ReportServer.dbo.[Users] [U1] ON S.[OwnerID] = [U1].[UserID]<br \/>\n-- Your Sharepoint Content Database<br \/>\nJOIN WSS_Content_.dbo.AllDocs D on D.Id = C.[ItemID]<br \/>\nJOIN WSS_Content_.dbo.Lists F on F.tp_ID = D.ListId<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I needed a way for me and my teammates to see and edit all report subscriptions across a Sharepoint site with SQL Reporting Services in Integrated mode. There are two parts here; the first is a function that returns text between delimiters. This is important to get the site and [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[2,10,11],"tags":[99,106,111],"class_list":["post-310","post","type-post","status-publish","format-standard","hentry","category-computer","category-sharepoint","category-software","tag-sharepoint-2010","tag-sql-reporting-services","tag-ssrs"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=310"}],"version-history":[{"count":0,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/310\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}