I am have sample JSON as below
{
"12345": {
"percent": 26,
"avgPrice": 32,
"avgNewOfferCount": 12,
"avgUsedOfferCount": -1,
"isFBA": true,
"lastSeen": 653
}
}
I am getting the array values but since my array head i.e. '12345' is not fixed but an ID I am not able to get it and I can't hardcode since ID will change.
I am trying as below:
SELECT @json j;
INSERT INTO [test].[test]
SELECT
JSON_VALUE(j.[value],$.j) AS key,
JSON_VALUE(j.[value],'$.percent') AS stat
FROM OPENJSON(@json) j;
But getting NULL in the key column.