{"id":374,"date":"2020-04-23T05:59:08","date_gmt":"2020-04-23T05:59:08","guid":{"rendered":"http:\/\/michaelschultz.net\/tech\/?p=374"},"modified":"2020-04-23T05:59:08","modified_gmt":"2020-04-23T05:59:08","slug":"configmgr-client-content-breakdown-sql-query","status":"publish","type":"post","link":"https:\/\/michaelschultz.net\/tech\/configmgr-client-content-breakdown-sql-query\/","title":{"rendered":"ConfigMgr Client Content Breakdown SQL Query"},"content":{"rendered":"\n<p>This SQL query for ConfigMgr current branch gives a breakdown of client content.\u00a0 It is also on my GitHub at <a href=\"https:\/\/github.com\/NecroMonkey\/vault\/blob\/master\/SQL\/ConfigMgr_content_source_breakdown.sql\">https:\/\/github.com\/NecroMonkey\/vault\/blob\/master\/SQL\/ConfigMgr_content_source_breakdown.sql<\/a><\/p>\n<p>\u00a0<\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:500px;\"><div class=\"text codecolorer\">drop table if exists ##temp1<br \/>\ndrop table if exists ##temp2<br \/>\n<br \/>\nSELECT distinct sysr.Name0,<br \/>\nsysr.ResourceID, ipr.Name as &amp;#91;Boundary],<br \/>\nipr.Value<br \/>\ninto ##temp1<br \/>\nFROM v_R_System sysr<br \/>\nJOIN System_IP_Address_ARR ip ON ip.ItemKey = sysr.ResourceID AND ip.NumericIPAddressValue &amp;lt;&gt; 0 &nbsp; &nbsp; <br \/>\nJOIN v_RA_System_IPSubnets sub ON sub.ResourceID = sysr.ResourceID &nbsp; &nbsp; &nbsp;<br \/>\nLEFT JOIN v_RA_System_IPv6Prefixes v6 ON v6.ResourceID = sysr.ResourceID<br \/>\nJOIN BoundaryEx AS ipr ON <br \/>\n-- Check BoundaryType 3 (IPRANGE)<br \/>\n(ipr.BoundaryType = 3 AND ip.NumericIPAddressValue BETWEEN ipr.NumericValueLow AND ipr.NumericValueHigh)<br \/>\n-- Check BoundaryType 1 (ADSITE)<br \/>\nOR (ipr.BoundaryType = 1 AND ipr.Value = sysr.AD_Site_Name0) <br \/>\n-- Check BoundaryType 0 (IPSUBNET)<br \/>\nOR (ipr.BoundaryType = 0 AND ipr.Value = sub.IP_Subnets0)<br \/>\n-- Check BoundaryType 2 (IPv6)<br \/>\nOR (ipr.BoundaryType = 2 AND ipr.Value = v6.IPv6_Prefixes0)<br \/>\norder by sysr.ResourceID<br \/>\n<br \/>\nselect rsys.Name0, rsys.ResourceID,<br \/>\n&quot;Content Source Type&quot; = CASE cdhs.DistributionPointType<br \/>\nWHEN 1 THEN 'Cloud DP (Distribution Point)'<br \/>\nWHEN 2 THEN 'Management Point'<br \/>\nWHEN 3 THEN 'Peer Cache'<br \/>\nWHEN 4 THEN 'DP (Distribution Point)'<br \/>\nWHEN 5 THEN 'BranchCache'<br \/>\nWHEN 6 THEN 'Delivery Optimization Peer'<br \/>\nWHEN 7 THEN 'Delivery Optimization Cache Server'<br \/>\nWHEN 8 THEN 'Microsoft Update'<br \/>\nEND,<br \/>\npackages.Name as &amp;#91;Content],<br \/>\ncdhs.ContentID,<br \/>\nCAST(SUM(cast(cdhs.BytesDownloaded as float)) \/ 1073741824 AS DECIMAL(10,2)) as &amp;#91;GB]<br \/>\ninto ##temp2<br \/>\nfrom<br \/>\nv_R_System as rsys<br \/>\njoin ClientDownloadHistory as cdh on rsys.ResourceID = cdh.ClientId<br \/>\njoin ClientDownloadHistorySources as cdhs on cdh.id = cdhs.DownloadHistoryID<br \/>\njoin ClientDownloadHistoryBoundaryGroups as cdhbg on cdh.id = cdhbg.DownloadHistoryID JOIN<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;v_FullCollectionMembership AS a ON rsys.ResourceID = a.ResourceID JOIN<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;v_Collection AS b ON b.CollectionID = a.CollectionID LEFT JOIN CI_Contentpackages CI on CI.Content_UniqueID = cdhs.ContentID <br \/>\nJOIN smspackages packages on packages.PkgID = ISNULL(CI.PkgID,cdhs.ContentId)<br \/>\nwhere (b.CollectionID = 'SMSDM003')<br \/>\ngroup by rsys.Name0, rsys.ResourceID, cdhs.DistributionPointType, packages.Name, cdhs.ContentID<br \/>\norder by rsys.Name0, rsys.ResourceID, cdhs.DistributionPointType, packages.Name, cdhs.ContentID<br \/>\n<br \/>\nselect<br \/>\nt1.Name0, t1.Boundary, t1.Value, t2.&amp;#91;Content Source Type], t2.Content, t2.GB<br \/>\nfrom ##temp1 as t1 join<br \/>\n##temp2 as t2 on t1.ResourceID = t2.ResourceID<br \/>\n<br \/>\ndrop table if exists ##temp1<br \/>\ndrop table if exists ##temp2<\/div><\/div>\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This SQL query for ConfigMgr current branch gives a breakdown of client content.\u00a0 It is also on my GitHub at https:\/\/github.com\/NecroMonkey\/vault\/blob\/master\/SQL\/ConfigMgr_content_source_breakdown.sql \u00a0<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,26,17],"tags":[],"class_list":["post-374","post","type-post","status-publish","format-standard","hentry","category-configmgr","category-queries","category-sql"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p98a2r-62","post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/comments?post=374"}],"version-history":[{"count":2,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/374\/revisions"}],"predecessor-version":[{"id":419,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/374\/revisions\/419"}],"wp:attachment":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/media?parent=374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/categories?post=374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/tags?post=374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}