I am trying to build a simple "Which nodes are not in AppStack?" query without re-creating all the logic used. If I cannot find the resultant nodes in a table somewhere then this is the best beginning I have focusing on just nodes in Appstack due to Applications and Virtual entities. Does this logic look like a correct beginning and is there a better way?
Select nodes.nodeid, nodes.caption, Nodes.IPAddress
,CASE WHEN Nodes.Applications.ApplicationID IS NOT NULL THEN 'YES' ELSE '' END AS [Applications]
,CASE WHEN Virtualmachines.nodeid IS NOT NULL THEN 'Yes' ELSE '' END AS [Virtual]
--,virtualmachines.nodeid,virtualmachines.ipaddress, virtualmachines.name
From Orion.Nodes
left outer JOIN Orion.VIM.VirtualMachines ON Nodes.ipaddress = VirtualMachines.ipaddress
--AND Virtualmachines.nodeid IS NULL
WHERE
--nodes.nodeid = 229
Nodes.Applications.ApplicationID IS NULL
AND Virtualmachines.nodeid IS NULL