SCCM SQL queries

List installed RAM for each computer

SQL query for the Configuration Manager database that lists the installed memory in GB for each computer, with a filter for low memory.

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

Memory decides if a computer can run a new Windows version or a heavy application. This query shows the memory of every computer.

The result shows each computer and its memory in GB. The computer with the least memory is at the top.

SQL
-- 0 = show all computers. 8 = show only computers with less than 8 GB.
DECLARE @LessThanGB INT = 0;

SELECT
    rs.Name0                                                           AS ComputerName,
    CAST(mem.TotalPhysicalMemory0 / 1024.0 / 1024.0 AS DECIMAL(10,1))  AS MemoryGB
FROM v_R_System rs
JOIN v_GS_X86_PC_MEMORY mem
    ON mem.ResourceID = rs.ResourceID
WHERE @LessThanGB = 0
   OR mem.TotalPhysicalMemory0 < CAST(@LessThanGB AS BIGINT) * 1024 * 1024
ORDER BY mem.TotalPhysicalMemory0, rs.Name0;

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. Run the query to list every computer.
  4. Change @LessThanGB to show only computers under that amount.

Good to know

  • v_GS_X86_PC_MEMORY stores TotalPhysicalMemory0 in KB. The view covers 64-bit computers too, in spite of its name.
  • The number is the memory Windows can use. It is a little under the size of the installed modules, so 8 GB shows as about 7.9.
  • The data comes from hardware inventory.
RAM memory v_GS_X86_PC_MEMORY v_R_System
✉

Get new articles in your inbox

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