The following sample query demonstrates how to join a site view to another site view. This query lists the boundaries for each site in the Configuration Manager hierarchy, the type of boundary, the boundary value, whether the connection is fast or slow, and the boundary description. The v_Site and v_BoundaryInfo site views are joined by using the SiteCode column. The query results are sorted by site code, boundary type, and then value. The CASE function is used to take a numeric value for boundary type and connection speed and to provide friendly names based on the value.
SELECT v_Site.SiteCode, v_Site.ServerName,
CASE v_BoundaryInfo.BoundaryType
WHEN 0 THEN 'IP subnet'
WHEN 1 THEN 'Active Directory
site'
WHEN 2 THEN 'IPv6 Prefix'
WHEN 3 THEN 'IP address
range'
END AS [Boundary Type],
v_BoundaryInfo.Value,
CASE v_BoundaryInfo.BoundaryFlags
WHEN 0 THEN 'Fast'
WHEN 1 THEN 'Slow'
END AS Connection, v_BoundaryInfo.DisplayName AS
Description
FROM v_BoundaryInfo INNER JOIN v_Site ON
v_BoundaryInfo.SiteCode = v_Site.SiteCode
ORDER BY v_Site.SiteCode, [Boundary Type],
v_BoundaryInfo.Value