SELECT DISTINCT TOP (100) PERCENT DisplayName0, Version0, COUNT(Version0) AS Total
GROUP BY DisplayName0, Version0
HAVING (DisplayName0 LIKE ‘%Adobe Reader%’)
ORDER BY Total DESC, DisplayName0
Recently, I needed a collection with all computers that do not have Adobe Reader 9 installed.
I created a collection with this query:
SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%Adobe Reader 9%". Everything was fine except the fact that my computer was also listed, despite the fact that I have Adobe Reader 9 installed. Well, I’m not an SQL geek but I know that
SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "%Adobe Reader 9%" should return all computers with Adobe Reader 9 installed. This one was ok – the collection listed only me. Something was wrong with my first query so I asked for help our SQL guys and in a few minutes I had the right query 🙂
Also, I didn’t want to install the Reader on server computers with SCCM client. So the final query looked like this:
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 inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_R_System.OperatingSystemNameandVersion not like "%Server%" and SMS_G_System_COMPUTER_SYSTEM.Name not in (select distinct SMS_G_System_COMPUTER_SYSTEM.Name from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId 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 "%Adobe Reader 9%")
I’m sure there are more ways to do this, but this is the query that worked for me.