Manually Quering Opsmgr Database pt2
In a previous post I found out the way to do basic queries to the opsmgr database. I got a request on what to do with two different objects with the same name. For example two SQL servers hosting a database with the same name. There is no way to distinguish them with my previous query. I found the following query would do the trick;
SELECT MEG.[Displayname] AS Object, LEFT(MEG.[PATH], CASE WHEN charindex(';' , MEG.[PATH]) > 0 THEN charindex(';' , MEG.[PATH]) ELSE 1 END - 1) AS Server, TMV.[Name] AS MonitoringClass, MEG.[Healthstate] FROM dbo.ManagedEntityGenericView AS MEG
INNER JOIN dbo.[ManagedTypeView] AS TMV
ON TMV.[id] = MEG.[MonitoringClassId]
WHERE MEG.[Displayname] = '
AND TMV.[Name] = 'Microsoft.SQLServer.Database'








