Quantcast
Viewing all articles
Browse latest Browse all 8827

Re: Compliance Report, Summarize & Count Multiple Violations Per Device

That got me thinking a bit and did a bit of research on XML in SQL databases.   A bit easier if the XML is actually stored in an XML datatype vs the nvarchar this field is stored in, but luckily a "CAST" seems to work. 

 

Try this, I think it actually works!!   Might need some tweaking, esp. changing <YOUR RULE NAME> to a specific rule, or removing that part of the query if you want a count of all violated rules...

 

SELECT  CAST(PCR.XmlResults AS XML).query('count(//Ps)'), PCR.RuleName, N.Caption, N.IP_Address FROM NCM_PolicyCacheResults PCR

  JOIN NCM_NodeProperties NP ON (NP.NodeID = PCR.NodeID)

  JOIN Nodes N ON (N.NodeID = NP.CoreNodeID)

WHERE (PCR.IsViolation = 1) AND (PCR.RuleName LIKE '%<YOUR RULE NAME>%')

GROUP BY N.NodeID, PCR.RuleName, N.Caption, N.IP_Address, PCR.IsViolation, PCR.XmlResults

ORDER BY N.Caption, PCR.RuleName

 

Kinda neat actually...


Viewing all articles
Browse latest Browse all 8827

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>