Skip to content
Advertisement

SQL Query on Json object inside multiple JSON objects

I have the below Json string. I need to write a query to get the TP records. Without providing the index value, we need get the result.

How do I query to get the TP values.

Expected Result:

Advertisement

Answer

You can use OPENJSON function containing WITH Clause added as many CROSS APPLY Clause as upto see all sub-arrays :

Demo

Update : If the first array S is fixed to contain only one item, we can reduce one-step as

Demo

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement