I'm new to JSON methods in SQL
I'm working with a huge JSON field, which has such a structure :
{
"A": 1,
"B": 2,
"C": 0,
"data": [
{
"id": "id_i_want",
"value": "[{
"prop1":7,
"prop2":"X",
"prop3":"4",
"passages":[
{
"id":0,
"number":"E24",
"date":"11/12/2019"
},
{
"id":0,
"number":"F28",
"date":"11/11/2019"
},
{
...
}
]
}]
},
{
"id": "id_i_do_NOT_want",
"value": Same structure as above
}
]
}
This JSON fields is stored in a nvarchar(MAX) field in SQLServer.
So the JSON has a property data
, which contains a list of elements.
These elements have a value
property, which contains a list of passages
.
All the passages
currently have id
= 0
What I need to do :
I would like ton increment all the id
of passages
, starting from 1, but only the ones in the object which has the ID id_i_want
, and NOT the others.
How can I do that with a SQL script ?
I tried to follow this post, but without success
Any help appreciated