This SQL script will show all target groups that need a given update. If using the Windows Internal Database (the default) rather than full SQL Server 2005, you can download Microsoft SQL Server Management Studio Express or sqlcmd.exe, and connect to the DB using this connection string: \\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query. The connection must be from the same machine. For example, to use sqlcmd to run this script: sqlcmd -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -I scriptLocation

Visual Basic
Edit|Remove
/*
Find all groups that need a given update
*/

USE SUSDB
SET NOCOUNT ON
DECLARE @UpdateId uniqueidentifier

-- Configure these values as needed
SELECT @UpdateId = '51BDD3D2-C81B-41D3-98CC-C8325152D590'
/*
-- To find the update ID from the update title (or partial title), use a query like this:
SELECT UpdateId, DefaultTitle
FROM PUBLIC_VIEWS.vUpdate
WHERE vUpdate.DefaultTitle = 'Security Update for Windows Vista (KB950582)'
*/

-- List of computer groups that have at least one computer that needs the update
SELECT vComputerTargetGroup.Name AS "Computer Group", COUNT (*) AS "Needed Count"
FROM PUBLIC_VIEWS.vComputerTargetGroup
INNER JOIN PUBLIC_VIEWS.vComputerGroupMembership on vComputerGroupMembership.ComputerTargetGroupId = vComputerTargetGroup.ComputerTargetGroupId
INNER JOIN PUBLIC_VIEWS.vComputerTarget on vComputerGroupMembership.ComputerTargetId = vComputerTarget.ComputerTargetId
INNER JOIN PUBLIC_VIEWS.vUpdateInstallationInfoBasic on vComputerTarget.ComputerTargetId = vUpdateInstallationInfoBasic.ComputerTargetId
WHERE      
vUpdateInstallationInfoBasic.State in (2, 3, 5, 6)
AND vUpdateInstallationInfoBasic.UpdateId = @UpdateId
GROUP BY vComputerTargetGroup.Name
ORDER BY vComputerTargetGroup.Name