Skip to content
SCCM SQL Query to Find Collections Used for App Deployment | ConfigMgr

SCCM SQL Query to Find Collections Used for App Deployment | ConfigMgr

Written By Ankit Shukla
Last Updated September 5, 2024
Posted In SCCM
SHARE

Let’s discuss SCCM SQL Query to Find Collections Used for App Deployment | ConfigMgr. In this post, I will explain the ConfigMgr Application, Packages, and collections used to deploy using the SQL query.

We shared many other SQL queries and custom reports with the HTMD Forum community. The following sections provide more details about the SCCM SQL Query to Find Collections Used for App Deployment.

In this post, we will see two different SQL queries that provide Information on Applications and Packages in your environment, including their deployed collection and Content source path.

The first query in this post will give you Information related to Packages and their relation to Collection and Advertisement. The second query will provide Information on the applications and to which collection it is deployed.

Patch My PC

SQL Query – Find Collections Used for App Deployment

This SQL Query will help you use the‘ when’ and ‘then ‘syntax. Follow the steps below to get the SCCM package or application collection details.

  • Open the SQL Management Studio.
  • Connect your Database Engine.
  • Right-click on your database CM_XXX and click on ‘New Query.’
  • Copy the following SQL query to find the application deployment report with collection details.
  • Click on the Execute button.
SCCM SQL Query to Find Collections Used for App Deployment | ConfigMgr- Fig.1
SCCM SQL Query to Find Collections Used for App Deployment | ConfigMgr- Fig.1

Package Advertisement and Collection

The SQL query below lets you check the package advertisement and collection details. You can use SQL Server Management Studio to get the reports.

select v_Package.Name 'Package Name',
v_Advertisement.PackageID,
v_advertisement.AdvertisementName,
v_Advertisement.AdvertisementID,
v_Collection.Name 'Collection Name',
v_Advertisement.CollectionID,
v_Package.PkgSourcePath
from v_Advertisement
inner join v_Package
on v_Package.PackageID=v_Advertisement.PackageID
inner join v_Collection
on v_Advertisement.CollectionID=v_Collection.CollectionID

Application and its Collection

Here is the query to get the reports of applications and their collection.

SELECT DISTINCT app.DisplayName AS 'Application Name',
aa.CollectionName AS 'Deployed to Collection',
aa.CollectionID,v_ContentInfo.ContentSource
FROM dbo.fn_ListDeploymentTypeCIs(1033) AS dt
inner join dbo.fn_ListLatestApplicationCIs(1033) AS app ON dt.AppModelName = app.ModelName
left outer join v_AppDeploymentSummary ads on app.CI_ID = ads.CI_ID
left outer join v_ApplicationAssignment aa on ads.AssignmentID = aa.AssignmentID
left outer join v_ContentInfo on DT.CONTENTID = V_CONTENTINFO.CONTENT_UNIQUEID
where aa.CollectionName not like '%NULL%'
Order by [Application Name];

Result of SQL Query

The two different SQL queries above will give you the result below.

  • Result of Package and Collection Query
SCCM SQL Query to Find Collections Used for App Deployment | ConfigMgr- Fig.2
SCCM SQL Query to Find Collections Used for App Deployment | ConfigMgr- Fig.2

Result of Application and Collection Query

SCCM SQL Query to Find Collections Used for App Deployment | ConfigMgr- Fig.3
SCCM SQL Query to Find Collections Used for App Deployment | ConfigMgr- Fig.3

References

We are on WhatsApp. To get the latest step-by-step guides and news updates, Join our Channel. Click here –HTMD WhatsApp.

Author

Ankit Shukla, an IT professional with over seven years of experience, has worked on SCCM/MECM since 2012. During this time, he has extensively dealt with various aspects of the tool, such as migration, infrastructure designing, OSD, custom SQL reporting, and client-side troubleshooting. Ankit’s blog posts reflect his hands-on experience addressing issues and providing practical solutions. The primary aim of his posts is to cater to

Written by

Hi,My Name is Ankit Shukla and I have been working in IT since 2012.For last 7 years I have been working on SCCM/MECM. In these years have worked on different features of this tool including Migration/designing the infrastructure/OSD/Custom SQL Reporting/Client Side troubleshooting and others.With my Blog Posts you will find my experience on the issues which i have faced and solutions for that.The major objective of these posts is to reach out the audience who are working as Support team members as SCCM Admins in their organizations.

Discussion

Join the discussion

Your email address will not be published. Required fields are marked *

Related guides

Intune

Windows 11 KB5101650 KB5099414 July 2026 Patch and 3 Zero Day Vulnerabilities and 570 Flaws

Key Takeaways Windows 11 KB5101650 KB5099414 July 2026 Patch and 3 Zero Day Vulnerabilities and 570 Flaws! In the July 2026 Patch, Microsoft introduced new features designed to improve the overall Windows experience. The update adds enhancements to Windows Update for more flexible update management and introduces Point-in-Time Restore, providing an additional recovery option for […]

AC Anoop C Nair 9 min read
Intune

2026 June KB5094126 KB5093998 Windows 11 Patch | 3 Zero Day Vulnerabilities and 200 Flaws

Key Takeaways 2026 June KB5094126 KB5093998 Windows 11 Patch | 3 Zero Day Vulnerabilities and 200 Flaws! The June 2026 Windows 11 Patch Tuesday update brings several improvements to File Explorer. It adds support for additional archive formats, including UU, CPIO, XAR, and NuGet Packages (NUPKG). The update also preserves View and Sort preferences in […]

AC Anoop C Nair 10 min read
Intune

2026 May KB5089549 KB5087420 Windows 11 Patch | 0 Zero Day Vulnerabilities and 120 Flaws

Key Takeaways The Windows 11 May 2026 Patch KB5089549 KB5087420 Update brings important security fixes, performance improvements, and reliability enhancements across the operating system. The update introduces new features such as Xbox Mode for gaming, File Explorer improvements, enhanced input and sharing experiences, better taskbar and Windows Hello reliability, and additional enterprise management capabilities for […]

AC Anoop C Nair 8 min read
SCCM

ConfigMgr 2603 Introduces New Early Update Enrollment Process

Key Takeaways In this post we are discussing the ConfigMgr 2603 Introduces New Early Update Enrollment Process. Microsoft has officially released Configuration Manager version 2603 to the Early Update Ring, giving organizations an opportunity to test upcoming improvements before the global production rollout. The release is targeted at enterprises running ConfigMgr version 2409 or later […]

AC Anoop C Nair 3 min read