I'm looking to only select each value name and value in the JSON string and pivot into separate columns in SQL so that I can easily pass these into a powershell string to send to an external API
DECLARE @json NVARCHAR(MAX)
SET @json='{ "InsertRecordData": { "data": { "AdditionalData": { "DataObjects": { "ObjData": { "Name": "coll_exclude", "Fields": { "FieldData1": { "Name": "agreement", "Value": "1234" }, "FieldData2": { "Name": "system", "Value": "live" }, "FieldData3": { "Name": "date_added", "Value": "2019-08-01" }, "FieldData4": { "Name": "time_added", "Value": "11:20" } } } } } } } }';
SELECT *
FROM OPENJSON(@json,'$.InsertRecordData.data.AdditionalData.DataObjects.ObjData.Fields')
So id want to see
Agreement System Date_added time_added
1234 live 2019-08-01 11:20