Freigeben über


Collection View Sample Queries

Betrifft: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2

The following sample queries demonstrate how to join some of the most commonly used collection views to other views.

Joining Collection Views

The following query lists the resources in the Configuration Manager 2007 hierarchy that are in a collection, the assigned site for client computers, the collection ID, collection name, and the last time the collection was refreshed. The v_FullCollectionMembership view is joined to the v_Collection view by using the CollectionID column. The query results are sorted by resource name and then by collection ID.

SELECT FCM.Name, FCM.SiteCode, FCM.CollectionID,

  COL.Name, COL.LastRefreshTime

FROM v_FullCollectionMembership FCM INNER JOIN v_Collection COL

  ON FCM.CollectionID = COL.CollectionID

ORDER BY FCM.Name, FCM.CollectionID

Joining Collection and Resource Views

The following query lists all of the discovered resources that are not installed as clients. The query lists the domain, computer name, and IP address using data by joining three views. The v_CM_RES_COLL_SMS00001 collection view is joined to the v_R_System and v_RA_IPAddresses discovery views by using the ResourceID column.

SELECT SYS.Resource_Domain_OR_Workgr0, COLL1.Name,

  SYSIP.IP_Addresses0

FROM v_CM_RES_COLL_SMS00001 COLL1

  INNER JOIN v_R_System SYS

  ON COLL1.ResourceID = SYS.ResourceID

  INNER JOIN v_RA_System_IPAddresses SYSIP

  ON COLL1.ResourceID = SYSIP.ResourceID

WHERE COLL1.IsClient = 0

ORDER BY SYS.Resource_Domain_OR_Workgr0, COLL1.Name

Joining Collection and Advertisement Views

The following query lists all of the resources in the Configuration Manager 2007 hierarchy that have been targeted for an advertisement, as well as the source site code, advertisement ID and advertisement name, program name, and target collection name, and then it sorts the data by the name of the resource. The v_FullCollectionMembership collection view is joined to the v_Advertisement software distribution view and v_Collection collection view by using the CollectionID column.

SELECT FCM.Name AS ResourceName, FCM.ResourceID,

  ADV.SourceSite, ADV.AdvertisementID, ADV.AdvertisementName,

  ADV.ProgramName, COL.Name AS CollectionName

FROM v_FullCollectionMembership FCM INNER JOIN v_Advertisement ADV

  ON FCM.CollectionID = ADV.CollectionID INNER JOIN

  v_Collection COL ON FCM.CollectionID = COL.CollectionID

ORDER BY FCM.Name

Siehe auch

Konzepte

Collection Views