Hi
In the SWQL table there is an array value such as 'AncestorsDisplayNames', and I want to retrieve only a single item from it.
For example, if the array contains ['Physical Memory', 'srv-1-prod'], how can I fetch just 'srv-1-prod'?"
BR
Hi
In the SWQL table there is an array value such as 'AncestorsDisplayNames', and I want to retrieve only a single item from it.
For example, if the array contains ['Physical Memory', 'srv-1-prod'], how can I fetch just 'srv-1-prod'?"
BR
What does your code look like?
Post up the SWQL query, it'll help
I’m not sure what query I should use. In MSSQL, I can use "JSON_VALUE
", but I’m not sure what query to write in SWQL.
If SWQL doesn’t have a function like JSON_VALUE
, I’d really like to know how to retrieve a specific element from a string[]
array.
What table are you looking at and i'll have a look?
You can use SUBSTRING and REPLACE, but usually there's a more efficient JOIN, might be worth expanding on the scenario
the full SWQL Functions list is here https://github.com/solarwinds/OrionSDK/wiki/SWQL-Functions
Hi
'AncestorsDisplayNames' fileld, in the volumes table. A typical value should look like this: ['Physical Memory', 'srv-1-prod']
Thanks
Here's a starter for your:
SELECT TOP 10 NodeID, Caption, ARRAYVALUEAT(SPLITSTRINGTOARRAY(AncestorDisplayNames),1) as Ancestor FROM Orion.Volumes
The SplitStringArray splits the text up on the comma separator and then the ArrayAtValue selects the second value (0 being the first) of the array.
I hope it helps!
Rich
Or as Adam correctly mentioned...
SELECT TOP 10 OV.NodeID, OV.Caption, OV.Node.Caption FROM Orion.Volumes AS OV
Works fine
Thanks!
Ok, Where is SPLITSTRINGTOARRAY documented at? That is amazing, and I don't remember ever seeing it.
SolarWinds solutions are rooted in our deep connection to our user base in the THWACK® online community. More than 200,000 members are here to solve problems, share technology and best practices, and directly contribute to our product development process.