我希望只选择 JSON 字符串中的每个值名称和值,并转入 SQL 中的单独列,以便我可以轻松地将它们传递到 powershell 字符串中以发送到外部 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')
所以我想看
Agreement System Date_added time_added
1234 live 2019-08-01 11:20