Count missing required updates per computer
SQL query for the Configuration Manager database that counts the required software updates each computer is missing, worst first.
LanguageSQL
What it does to the systemReads only. It changes nothing.
A few computers often hold most of the missing patches. This query finds them so you can fix the worst ones first.
The result shows each computer with the number of updates it needs and the time of its last check. The highest count is at the top.
SQL
-- Show only computers that miss at least this many updates.
DECLARE @MinMissing INT = 1;
SELECT
rs.Name0 AS ComputerName,
COUNT(DISTINCT ucs.CI_ID) AS MissingUpdates,
MAX(ucs.LastStatusCheckTime) AS LastCheck
FROM v_UpdateComplianceStatus ucs
JOIN v_UpdateInfo ui
ON ui.CI_ID = ucs.CI_ID
JOIN v_R_System rs
ON rs.ResourceID = ucs.ResourceID
WHERE ucs.Status = 2 -- 2 = required, not installed
AND ui.IsSuperseded = 0
AND ui.IsExpired = 0
GROUP BY rs.Name0
HAVING COUNT(DISTINCT ucs.CI_ID) >= @MinMissing
ORDER BY MissingUpdates DESC, rs.Name0;
How to use it
- Open SQL Server Management Studio and connect to the site database.
- Paste the query into a new query window.
- Run the query to see every computer that misses at least one update.
- Raise
@MinMissingto see only the worst computers. - To count only updates you deployed, add the line
AND ui.IsDeployed = 1to the WHERE block.
Good to know
- The count covers every update in your catalog that the computer reports as required. It includes updates you have not deployed.
- The query skips superseded and expired updates.
- A computer that never ran an update scan does not show. Check the scan state of those computers on its own.
software updates
missing updates
v_UpdateComplianceStatus
v_UpdateInfo
More SCCM SQL queries
Check software update compliance for one update
Check BitLocker protection status for each computer
Check distribution point content status for a package
Count computers by manufacturer and model
Count Configuration Manager client versions in your environment
Count installs per application and version