Sql-server – Separating system databases from MDW SQL Server 2008 R2

management-data-warehousesql serversql-server-2008-r2

We have the Management Datawarehouse feature configure on two of our SQL Servers. Both point to the same central database and upload their results to it.

Everything works fine with the built in reports run from the instance. However, I am taking all the data from the snapshots.diskusage table to help show how our databases have grown and formulate a storage solution for the next chunk of time. For the majority our databases are uniquely named so there is no concern there running:

SELECT * 
FROM [RKYV_MDW].[snapshots].[disk_usage]
WHERE database_name = 'tempdb'

The tricky part comes with the system databases, of particular annoyance is tempdb. Seeing as both instances have a tempdb and upload their stats I have double the number of data points and the graphs turn out somewhat meaningless. I can't see anything in the table bar snapshot_id that might help me seperate the two out but I am unsure where this would be unique to a particular instances tempdb.

Does anyone have any thoughts about this? My alternative is to select every other line (from a quick ganders at the data) but feel there must be a more elegant way out there.

Best Answer

Join via snapshots_internal to source_info_internal which has the server instance name, eg

SELECT du.*, sii.instance_name
FROM [snapshots].[disk_usage] du
    INNER JOIN core.[snapshots_internal] si ON du.snapshot_id = si.snapshot_id
        INNER JOIN [core].[source_info_internal] sii ON si.source_id = sii.source_id
WHERE du.database_name = 'tempdb'