How to QUERY the WSUS DB

You are here:
< Back

SELECT m.TargetID, m.FullDomainName, h.NotInstalled,
(SELECT COUNT(*) AS NoAprobados FROM tbUpdateStatusPerComputer j
WHERE (m.TargetID = j.TargetID) AND (j.SummarizationState = 2)) AS NotApproved,
(SELECT COUNT(*) AS NotApproved FROM tbUpdateStatusPerComputer k
WHERE (m.TargetID = k.TargetID)
AND (k.SummarizationState = 2)) – h.NotInstalled + h.Downloaded + h.Failed AS PendingInstall, h.Unknown, h.Downloaded, h.Installed, h.Failed, h.InstalledPendingReboot, h.LastChangeTime, m.LastSyncTime, m.LastReportedStatusTime, m.LastReportedRebootTime, m.EffectiveLastDetectionTime
FROM tbComputerTarget m JOIN tbTargetInTargetGroup i
ON m.TargetID = i.TargetID JOIN tbTargetGroup g
ON g.TargetGroupID = i.TargetGroupID JOIN tbComputerSummaryForMicrosoftUpdates h
ON h.TargetID = m.TargetID
ORDER BY FullDomainName