All, I am looking for some SWQL/SQL code that can pull out the following information from the database.
Columns include:
I didn't look at the output or what you were trying to do, just fix the query to allow it to output.
If you look at the <span class="s11">Cirrus</span><span class="s10">.</span>EntityPhysical entity, you will see there are multiple rows for each of the physical elements on the node. Therefore, you simply need to add a WHERE clause to restrict what you actually want to see. For example, you may only be interested in the Chassis, in which case the clause would be
<span class="s11">Cirrus</span><span class="s10">.</span>
EntityPhysical
<span class="s11">WHERE [Device].EntityClass LIKE '%chassis%'</span>
More likely, just interested in devices and the elements that have serial numbers, so this would be
<span class="s5">WHERE</span><span class="s0"> </span><span class="s10">[</span><span class="s11">Device</span><span class="s10">].</span><span class="s11">Serial</span><span class="s0"> </span><span class="s10"><></span><span class="s0"> </span><span class="s7">''</span>
Sidebar: You might want to change the WHERE clause (to trap for NULLs). It's generally best practices because NULL is not the same as an empty string ('').
NULL
''
WHERE [Device].Serial <> ''
to
WHERE IsNull([Device].Serial, '') <> ''
Isn't almost all of that information in Cirrus.Nodes?
Cirrus.Nodes
SELECT [Nodes].NodeCaption , [Nodes].AgentIP , [Nodes].Vendor , [Nodes].MachineType , [Nodes].OSImage , [Nodes].OSVersion , [Nodes].EndOfSupport , [Nodes].EndOfSales , [Nodes].EndOfSoftware , [Device].SerialFROM Cirrus.Nodes AS [Nodes]LEFT JOIN Cirrus.EntityPhysical AS [Device] ON [Nodes].NodeID = [Device].Serial
I am getting an error when I cut and paste into a Custom Query. (SWQL)
The JOIN was not correctly mapped, try this
SELECT [Nodes].NodeCaption , [Nodes].AgentIP , [Nodes].Vendor , [Nodes].MachineType , [Nodes].OSImage , [Nodes].OSVersion , [Nodes].EndOfSupport , [Nodes].EndOfSales , [Nodes].EndOfSoftware , [Device].SerialFROM Cirrus.Nodes AS [Nodes]LEFT JOIN Cirrus.EntityPhysical AS [Device] ON [Nodes].NodeID = [Device].NodeID
thanks, sample output. It will list the device several times.
Thanks @m_roberts. That was obviously a bad edit considering I don't have any matching data at all in my lab and I was trying to remember the linkages.