Below is the SQL code needed to retrieve all of the collections from ConfigMgr. This is useful when creating custom reports that need to be scoped to a specific collection. The query below selects the CollectionName and CollectionID columns and sorts the CollectionName column alphabetically.
SELECT CollectionName, CollectionID
FROM v_Collections
ORDER BY CollectionName
Results from the query on my test system.
