SCCM SQL queries

List the members of a collection

SQL query for the Configuration Manager database that lists every member of a collection you name, with domain, site code and client state.

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

Sometimes you need the member list of a collection outside the console. For example, to compare two collections or to send a list to another team.

The result shows the collection, each member name, the domain, the site code and if the member has a client.

SQL
-- Type the exact name of the collection.
DECLARE @CollectionName NVARCHAR(255) = 'All Workstations';

SELECT
    c.CollectionID AS CollectionID,
    c.Name         AS CollectionName,
    fcm.Name       AS MemberName,
    fcm.Domain     AS Domain,
    fcm.SiteCode   AS SiteCode,
    fcm.IsClient   AS HasClient
FROM v_Collection c
JOIN v_FullCollectionMembership fcm
    ON fcm.CollectionID = c.CollectionID
WHERE c.Name = @CollectionName
ORDER BY fcm.Name;

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 @CollectionName to the exact name of your collection.
  4. Run the query.
  5. To use a collection ID, change the WHERE line to c.CollectionID = 'ABC00012'.

Good to know

  • The query works for device collections and user collections.
  • The list is as fresh as the last membership evaluation of the collection.
collection collection members v_FullCollectionMembership v_Collection
✉

Get new articles in your inbox

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