I have used this several times, but much of the information I see on the Internet is incorrect or has some sort of typo in the syntax. Bellow is a query you can use for a collection for all systems that do not have Microsoft SQL Server 2005 installed. You can change the display name to any application to change the results.
select SMS_R_System.ResourceID,SMS_R_System.ResourceType,SMS_R_System.Name,SMS_R_System.SMSUniqueIdentifier,SMS_R_System.ResourceDomainORWorkgroup,SMS_R_System.Client from SMS_R_System where ResourceId not in (SELECT SMS_R_System.ResourceID FROM SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like 'Microsoft SQL Server 2005' )
Here is one that should work for 2 applications. Sim[ply change the 2 display names in bold. To add a third or more, copy everything from what's in red and below to the end of the query and change the display name again.
select SMS_R_System.ResourceID,SMS_R_System.ResourceType,SMS_R_System.Name,SMS_R_System.SMSUniqueIdentifier,SMS_R_System.ResourceDomainORWorkgroup,SMS_R_System.Client from SMS_R_System where ResourceId not in (SELECT SMS_R_System.ResourceID FROM SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like 'Microsoft SQL Server 2005' ) or ResourceId not in (SELECT SMS_R_System.ResourceID FROM SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like 'Security Update for Windows Server 2003 (KB890046)' )
Brian S. Tucker
The Blogcast Repository - MCSE, MCDBA, MCT & MCTS