How to create a SCCM Query

Here is the basic principal to creating your queries, in the SCCM console there is a section called “Queries”

clip_image002

 

Right Click on Queries,

clip_image004

Or select ‘New’ from the Actions Tab

clip_image005clip_image007

Here is your empty Query Box,

clip_image009

Then select the ‘Object Type’

clip_image011

 

Then click on the ‘Edit Query Statement’

clip_image014

Which in turn will open the ‘Query Statement Properties’

clip_image016

I am going to choice the “Criteria” Tab

clip_image019

Click on the Star/Sun,

clip_image021

For this Query I am going to choice the ‘Criterion Type’ to ‘Prompted’

clip_image023

As above,

The  click the ‘Select’ button

clip_image025

 

This opens the ‘Select Attribute’ dialog

clip_image027

My selections look like this,

clip_image029

 

 

 

 

 

 

 

 

Now our ‘Criterion Properties’ look like this,

clip_image031

Click OK,

The wizard has created a Statement like this,

select *  from  SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_OPERATING_SYSTEM.BuildNumber = ##PRM:SMS_G_System_OPERATING_SYSTEM.BuildNumber##

Click OK again back to the starting point

clip_image033

Are query is ready to run.

clip_image034clip_image036

 Double Click our query,

As we asked for a ‘Prompted Value’ we get a dialog box,

clip_image038

So I looking for all the Windows 7 machines in our SCCM Site

clip_image040

I enter the Build Number ‘7100’

And it has returned all of our Windows 7 machines

clip_image042

 

OK so this is a simple query but let just recap on what we have done,

Using the SCCM Query Wizard we have safely queried the information in the Complex SCCM database sorted out what we what added a prompt got the results we wanted in 5 mins. If you have read this far in my blog there is a chance you may be new to SCCM Queries, if so you’re on your way to learning how to create SCCM Queries. This is a really simple query and they can get a lot more complex. If you manage to find the results you want in a simple query or a more complex one the point is that you have the result you want.

 

 

 

Leave a Reply