SCCM SQL queries

Find computers with no hardware inventory in 30 days

SQL query for the Configuration Manager database that lists clients with a last hardware scan older than a number of days, or no scan at all.

LanguageSQL
What it does to the systemReads only. It changes nothing.

Most reports in Configuration Manager use hardware inventory. A client that stops sending inventory gives you old or missing data.

The result shows each client with an old scan date or no scan date. It also shows the days since the last scan.

SQL
-- Change this number to set the limit in days.
DECLARE @Days INT = 30;

SELECT
    rs.Name0                                 AS ComputerName,
    rs.Client_Version0                       AS ClientVersion,
    ws.LastHWScan                            AS LastHardwareScan,
    DATEDIFF(DAY, ws.LastHWScan, GETDATE())  AS DaysSinceScan
FROM v_R_System rs
LEFT JOIN v_GS_WORKSTATION_STATUS ws
    ON ws.ResourceID = rs.ResourceID
WHERE rs.Client0 = 1
  AND ISNULL(rs.Obsolete0, 0) = 0
  AND (ws.LastHWScan IS NULL
       OR ws.LastHWScan < DATEADD(DAY, -@Days, GETDATE()))
ORDER BY ws.LastHWScan;

How to use it

  1. Open SQL Server Management Studio and connect to the site database.
  2. Paste the query into a new query window.
  3. Change @Days to the limit you want.
  4. Run the query.
  5. Check the rows with an empty scan date first. Those clients never sent inventory.

Good to know

  • The query uses a LEFT JOIN so clients with no inventory record still show.
  • A computer that is turned off for a long time also shows here. Check it against your inactive clients.
hardware inventory client health v_GS_WORKSTATION_STATUS v_R_System
✉

Get new articles in your inbox

SCCM guides, AI tools, automation tips — sent when published. No spam.