我有一个以下 JSON
{
"href": {
"host": "localhost",
"port": 2222
},
"name": "20190812",
"scheduledStartTime": "2019-08-12T12:22:52.500-04:00",
"parameters": {
"1251226": {
"value": {
"instanceID": 219002,
"productName": "product1",
"userID": "admin"
}
},
"1251287": {
"value": {
"sgName": "sg1",
"userID": "admin"
}
}
}
}
我想遍历 JSON 并一个一个地处理每个迭代。我尝试使用虽然将 JSON 的长度作为计数,但无法弄清楚如何一一获取值
在 SQL Server 2016 中甚至有可能吗?
到目前为止我试过这个
Declare @count INT
select @count = COUNT(*)
FROM OPENJSON((select template_data_mapping from template_data_mapping), N'$')
WHILE @count != 0
BEGIN
SELECT @count
SET @count = @count - 1;
END;