< Blog

How Queries Are Processed

By Garth Jones

A question that comes up from time to time is about how to locate PCs that do not have a specific type of software installed.

A common mistake is to think that you need to use either Not Equal To or Not Like within a query. However, by using these operators in your query the end result will show every PC within System Center Configuration Manager. I will explain why this is true, but let’s first talk about how queries are processed.

How Queries Are Processed

Before looking at queries that contain Not Equal To or Not Like we need to understand what Equal To or Like means in a query. As a general rule, when a query is run a query will process each row within a view or a table.

For our example we will query to find all PCs with Microsoft Project 2010. Using the following table, let’s see how this query with the Equal To operator is processed. This table is comprised of 4 PCs and their add/remove program (ARP) details.

PC NamePC1PC2PC3PC4
1Adobe Reader XIMicrosoft Project 2010Visio 12Adobe Reader X
2Visio 12CorelDrawITunesMicrosoft Project 2010
3ITunesOffice 2010WordStarDataStar
4Microsoft Office 2013Lotus123
5Kix 2010

Remember, our main concern is to find all of the PCs with Microsoft Project 2010 installed.

1. Starting with PC1, the query will review each row to look for Microsoft Project 2010. The software is not found in any of PC1’s rows.

2. The process is repeated with PC2. This time Microsoft Project 2010 is found and PC2 is added to the result set.

3. The process is repeated with PC3. The software is not found in any rows for PC3.

4. The process is repeated with PC4. This time Microsoft Project 2010 is found in row 2 and PC4 is added to the result set.

5. Finally, the result set for the query will return PC2 and PC4.

Looking at the table above, this information is exactly what we expected to see in our result set.

Over my next five blog posts, I will explain how the Not Equal To query is processed and how to use a subselect query to locate PCs that do not have a specific type of software installed.

How a “Not Equal To” Query is Processed
The Subselect Query
Subselect Query for Reports (SQL)
Subselect Query for SCCM Queries or Collections (WQL)

Subselect WQL Query to Find PCs That Do Not Have Either x86 or x64 Versions of Software Installed