Skip to content
SCCM Patch Status SQL Query Based on Particular Collection | ConfigMgr

SCCM Patch Status SQL Query Based on Particular Collection | ConfigMgr

Written By Deepak Rai
Last Updated June 24, 2024
Posted In SCCM
SHARE

Let’s find out SCCM Patch Status SQL Query Based on Particular Collection. I have seen many questions in HTMDForum that we want the patch report, how to write a SQL query to write a report on patching, etc.

In this post, you will learn how to make a working SCCM patch status SQL query to find the patch status from your configuration manager (a.k.a ConfigMgr) database. You can customize the query as per your needs.

The following is a sample query that will help you understand the tables and views required to get the SCCM patching report working. Hence, we have done a formidable job for you.

When setting up your query, remember to replace the Collection ID, Article ID, and, optionally, the BulletinID to ensure that the query works correctly. This customization will help tailor the query to your needs and provide you with relevant information.

Patch My PC
Index
SCCM Patch Status SQL Query
Results – SCCM Patch Status SQL Query Based on Particular Collection
SCCM Patch Status SQL Query Based on Particular Collection | ConfigMgr – Table 1

NOTE! – Many other SCCM custom reports are available from Karthikeyan in the following post. SQL Query All SCCM Applications with no Deployments | ConfigMgr.

SCCM Patch Status SQL Query

Once you have initiated the client push installation method, you can track the patch installation status (a.k.a. patching) using the following query. This is the simplest way to get the patch reports from ConfigMgr.

  • Open the SQL Management Studio.
  • Click on the New Query button.
  • Select the CM_MEM database from the drop-down menu.
    • MEM is the ConfigMgr site code.
  • Copy the following SQL query to find the report for particular patches.
  • Click on the Execute button.
SCCM Patch Status SQL Query Based on Particular Collection | ConfigMgr - Fig.1
SCCM Patch Status SQL Query Based on Particular Collection | ConfigMgr – Fig.1

NOTE! – Make sure to replace collection IDs, Article IDs, and Bulletin IDs before running the query.

/*Selected KB Article ID patch required or installed status for Specific Collection ID*/
Declare @Collection varchar(8)
Set @Collection = 'SMS00001' /*Enter the collection ID*/
Select
Distinct VRS.Name0 as 'MachineName',
Os.Caption0 as 'OperatingSystem',
St.SystemType00 as 'OSType',
VRS.AD_Site_Name0 as 'ADSite',
VRS.Full_Domain_Name0 as 'Domain',
VRS.User_Name0 as 'UserName',
UI.ArticleID as 'ArticleID',
UI.BulletinID as 'BulletinID',
UI.Title as 'Title',
CASE WHEN UCS.Status = 2 THEN 'Required'
WHEN UCS.Status = 3 THEN 'Installed'
ELSE 'Unknown' END AS 'KBStatus',
UI.InfoURL as 'InformationURL'
FROM v_UpdateComplianceStatus UCS
INNER JOIN v_UpdateInfo UI ON UCS.CI_ID = UI.CI_ID
INNER JOIN v_CICategories_All CIC ON UI.CI_ID = CIC.CI_ID
INNER JOIN v_CategoryInfo CI ON CIC.CategoryInstanceID = CI.CategoryInstanceID
INNER JOIN v_R_System VRS ON UCS.ResourceID = VRS.ResourceID
INNER JOIN v_GS_OPERATING_SYSTEM Os on UCS.ResourceID = Os.ResourceID
INNER JOIN Computer_System_DATA St on UCS.ResourceID = st.MachineID
INNER Join v_FullCollectionMembership Col on UCS.ResourceID = Col.ResourceID
WHERE VRS.Operating_System_Name_and0 like '%Workstation%'
and Col.CollectionID = @Collection
and UI.articleid in ('4561600','4557957','4025338') /*Enter the article ID*/
and UI.BulletinID in ('ms17-010','ms17-008') /*Enter the Bulletin ID*/
and active0 = 1 and client0 = 1
Order by 10

Results – SCCM Patch Status SQL Query Based on Particular Collection

The SQL query for patch status is very helpful in terms of troubleshooting software update issues. I have seen many scenarios where SCCM admins struggle to install the details patches on Windows 10 devices.

SCCM Patch Status SQL Query Based on Particular Collection | ConfigMgr - Fig.2
SCCM Patch Status SQL Query Based on Particular Collection | ConfigMgr – Fig.2

Resources

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

Author

Deepak Rai is a Technical Lead with over 14 years of experience in IT. He specializes in SCCM, Intune, and Azure. Throughout his career. Deepak has worked on various platforms such as Active Directory, Exchange, Veritas NETBACKUP, Symantec Backup Exec, NDMP devices like Netapp, EMC Data Domain, Quantum using Backup Exec 2010 and 2012, and HP StorageWorks 4048 MSL G3. He also has experience in data deduplication-related troubleshooting. Ultimately, he returned to his roots as an IT Engineer focusing on SCCM technology.

Written by

My name is Deepak Rai and i am Technical Lead on SCCM and Intune with more than 14 years of experience in IT. My main domain is SCCM 2012, CB, MECM, Intune and Azure (Runbooks). I have worked on several platforms (Active Directory, Exchange, Veritas NETBACKUP, Symantec Backup Exec NDMP devices Like Netapp, EMC Data Domain, Quantam using Backup Exec 2010 and 2012, HP storage works 4048 MSL G3 , Data Deduplication related troubleshooting.) in these 13 years but finally ended up to the technology from which i started as IT Engineer (SCCM).

Discussion · 13 comments

  1. Hello,

    Is it possible to know the patch installed status(Installed, Failed or timed out etc.,) along with error codes(0, 3010, 1618, etc.,)

    Example with the below fields:

    Collection Name, Host Name, OS Name, Patch Update Name, Status, Installed date

    Thank you.

  2. Hi,
    I’m using your query, and the issue i have is that some servers that aren’t being reported
    – i checked those few odd servers not being reported, and they are a member of my “All Windows Server Collection” i am targeting
    – i thought it might be because those servers do not actually have a Software Update Group being deployed to them—which is true. However, I have other servers the query is returning which also don’t have any SUG being deployed to them. So that doesn’t seem to be the case.
    – i used the third party recast tool, and for the most part, the reported servers and unreported servers appear to have all the same collection memberships

    Any idea why a few servers are not showing up on this query?

    1. StaffHello Brian,

      Sure we can look into it. So first thing is if the servers which are not reporting the compliance data have SCCM Client installed and healthy in the console. If Client is healthy then we need to check if software update scan is completing for those servers and state message is being forwarded to the SCCM. For prompt response and further troubleshooting let’s take it to our forum http://forum.howtomanagedevices.com/ and we can work together to fix this issue.

  3. Hello,

    I tried this query, it’s executing successfully but some how I am getting result only for 2 devices as install and not installed updates result. in collection we have 15 devices. Any idea for those Inactive or Noclient devices

  4. I just found this query it is precisely what I need in time sensitive situation. However, although I know the KB is installed the query returns no results. I am trying to query for KB5040422/MS24-JUL3. I have edited the UI.articleid and UI.bulletinID, articleID with and without KB#######, bulletinid with and without upper case the query runs no errors but no results either. Any suggestions as to what I did wrong

  5. We have 3 patches deployed everymonth. Third party , Office patches and microsoft patches and we wanted to get compliance for all the machines of all the patches in a single query from SCCM. Do we have chance for that

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