Reporting associations can be very challenging especially since you have to figure out what the resource type guid is for the two sides of the relationship you are trying to report. Well, there is a wonderful report with a HUGE number of examples of relationships called the Resource Management Metadata report.
Here is an example where you can get the code needed to add an asset's status to a report:
/* and */ indicate the beginning and ending of a comment. Comments can span lines.
You can remove extra spaces and add new lines as you wish.
/* Asset's Status Association sample query. */ SELECT parent.[Name] AS [Asset] , rt.[Name] AS [Resource Type], ISNULL(child.[Name], 'Active') AS [Asset's Status] FROM vResourceEx parent INNER JOIN ResourceType rt ON parent.[ResourceTypeGuid] = rt.[Guid] LEFT OUTER JOIN ResourceAssociation ra ON parent.[Guid] = ra.[ParentResourceGuid] AND ra.[ResourceAssociationTypeGuid] = '3028166f-c0d6-41d8-9cb7-f64852e0fd01' LEFT OUTER JOIN vResourceEx child ON ra.[ChildResourceGuid] = child.[Guid] /* Limit results to all resources with 'Asset' as a base resource type */ WHERE parent.[ResourceTypeGuid] IN (SELECT ResourceTypeGuid FROM ResourceTypeHierarchy rth INNER JOIN ResourceType rt ON rth.[BaseResourceTypeGuid] = rt.[Guid] WHERE rt.[Name] = 'Asset')
Now you may want to take this code to add to another report. You can modify the report you created with the sample code or you can take parts of the code to another report. For example, you can add Location to a report, whether it is one you wrote or one that came with the system.
This report will be very useful if you are trying to locate a machine where you only know its MAC address. You are going to copy the sample code for Location and add the table and field for MAC Address to that code. You will then take the modified code and create a new report with it.
/* Location Association sample query. */ SELECT parent.[Name] AS [Asset] , rt.[Name] AS [Resource Type] , ISNULL(child.[Name], 'No Association') AS [Location], tcpip.[MAC Address] FROM vResourceEx parent INNER JOIN ResourceType rt ON parent.[ResourceTypeGuid] = rt.[Guid] LEFT OUTER JOIN ResourceAssociation ra ON parent.[Guid] = ra.[ParentResourceGuid] AND ra.[ResourceAssociationTypeGuid] = '05de450f-39ea-4aae-8c5f-77817889c27c' LEFT OUTER JOIN vResourceEx child ON ra.[ChildResourceGuid] = child.[Guid] INNER JOIN Inv_AeX_AC_TCPIP tcpip ON parent.[Guid] = tcpip.[_ResourceGuid] /* Limit results to all resources with 'Asset' as a base resource type */ WHERE parent.[ResourceTypeGuid] IN (SELECT ResourceTypeGuid FROM ResourceTypeHierarchy rth INNER JOIN ResourceType rt ON rth.[BaseResourceTypeGuid] = rt.[Guid] WHERE rt.[Name] = 'Asset')