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
Here's a starter for your:
SELECT TOP 10NodeID, Caption, ARRAYVALUEAT(SPLITSTRINGTOARRAY(AncestorDisplayNames),1) as AncestorFROM 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
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.
JSON_VALUE
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.
string[]
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
'AncestorsDisplayNames' fileld, in the volumes table. A typical value should look like this: ['Physical Memory', 'srv-1-prod']
Thanks
Or as Adam correctly mentioned...
SELECT TOP 10OV.NodeID, OV.Caption, OV.Node.CaptionFROM Orion.Volumes AS OV