This is a working index of the SCCM/Configuration Manager SQL and WQL queries published across the site, organised by what they’re actually used for so you can find the right one without hunting through the archive. Every query here has a full walkthrough on its own page – click through for the complete query text, where to run it, and any prerequisites (permissions, which view/table it hits, etc.).
How to Use This Library
- SQL queries are written against the ConfigMgr site database (
CM_<SiteCode>) and are meant to be run in SQL Server Management Studio (SSMS), or dropped into an SSRS report if you want them refreshing automatically - WQL queries are written for the ConfigMgr console itself – paste them into a Collection’s Membership Rules > Query Rule editor, or use them for a query-based Collection you want to keep live and self-updating
- Always run a new query against a test collection or with
TOP 100/ aWHEREfilter first – some of these touch tables with millions of rows on a large hierarchy and can be slow if run unfiltered - Use a read-only SQL account for reporting queries where one is available – you don’t need write access to the CM database to pull inventory data
- This page is a living index – it gets new entries as new queries are published
SQL vs. WQL – Which One Do I Need?
Short version: if you want a report (a list, a count, an export to CSV), you want SQL, run against the site database in SSMS. If you want a live Collection that ConfigMgr keeps updated on its own membership evaluation schedule – so you can target a deployment at it – you want WQL, entered directly into the Collection’s query rule. A few of the queries below exist in both flavours because the underlying question (“which machines have X installed?”) is useful both ways.
Windows OS & Discovery Queries
- SCCM SQL Query: Count Different Operating Systems in Your Environment
- SCCM Newly Discovered Devices: SQL Query for the Last 24 Hours
Software & Application Inventory Queries
- SCCM Collection Query for Devices with Specific Software Installed and Version or Below
- SCCM SQL Query for Software Not in Add/Remove Programs
- SCCM SQL Query – Google Earth Installs
- Configuration Manager SQL Query for Installed Software Per Machine & Per Collection
- SCCM SQL Query Machines: Finding All Devices with SQL Installed
Client Health & Compliance Queries
- SCCM WQL Query – No ConfigMgr Client Installed
- SCCM WQL Query – Clients Without Latest Version Installed
- SCCM Inactive Clients: A WQL Query to Find Every One
- SCCM WQL Query: ConfigMgr Client Installed but Missing SCEP
- SCCM WQL Query: Machines Without Endpoint Protection Installed
Hardware & Asset Reporting Queries
- SQL Queries Configuration Manager: Reporting Device Make and Model
- SCCM Collection Query for Virtual Machines
- SCCM SQL Query for Hardware and Client Version Reporting
- SCCM SQL Query for All Server CPU Information
- SCCM SQL Query: Pulling Laptop Inventory Data
- SCCM SQL Query – Count Computers by Model
- Configuration Manager SQL Query: Reporting Machine Count by Manufacturer
- SCCM Report Query for Machine Make and Model Count
- SCCM SQL Query: Finding Machines with Low Disk Space
- SCCM SQL Query: Pulling Server Information from the Database
- SCCM Last Logged On User: Query for All Systems
Site, Role & Database Queries
- ConfigMgr SQL Query – ConfigMgr Clients Installed Per AD Site
- SCCM SQL Query: Pulling Hierarchy Information from the Database
- ConfigMgr SQL Query: Retrieving Site Roles from the Database
- SQL Query Active Directory: Finding Security Group Members – not a ConfigMgr query, but included here since it’s the same SSMS/T-SQL skill set applied to an AD-integrated database
WQL Collection Queries (Device Targeting)
These are written specifically to drop into a Collection’s query rule so the membership stays live and self-updating – useful when you want a deployment to automatically pick up new matching devices.
- SCCM WQL Collection Query for All WinRAR Installations
- SCCM WQL Query – All Windows 10 Installs
- SCCM WQL Query: Finding Machines with 4GB RAM or More
- SCCM WQL Query: Finding Devices with Specific Software Installed
- SCCM WQL Query: Finding Machines with Less Than 1GB RAM
- SCCM WQL Query: Machines with a Valid Hardware Scan in X Days
- SCCM WQL Query: Prompting for a Device’s MAC Address
- SCCM WQL Query: Finding Devices with Google Earth Installed
One More Worth Bookmarking
If you want a single roundup to skim rather than browsing by category, 30 Useful SCCM SQL Queries covers a broad mix in one place – several overlap with the categorised list above, but it’s a handy quick-reference on its own.
Have a query you’d like to see covered, or found one of these needs updating for a newer ConfigMgr build? Let us know via the contact page and we’ll look at adding or refreshing it.
Discover more from TechyGeeksHome
Subscribe to get the latest posts sent to your email.