I have a column in SQL table which has a string value denoting a JSON array. I need to concatenate the array for comparison. There are multiple rows of this data and will be using a CURSOR to iterate through a set of values because no example of using using OPENJSON on a column is available
there are solutions for iterating the array in a property ('$.list') of a JSON but nothing which talks about a direct array.
from:
| ID | Value |
|---|---|
| 1 | [{"id": 1, "val":"j"}, {"id": 2,"val":"o"}, {"id": 3, "val":"h"}, {"id": 4, "val":"h";}, {"id": 5, "val":"n"}] |
| 2 | [{"id": 1, "val":"d"}, {"id": 2,"val":"o"}, {"id": 3, "val":"e"}] |
Result:
| ID | Result |
|---|---|
| 1 | john |
| 2 | doe |
and then proceed with my other iteration logic on the Result table
"characters would be invalid JSON, because the standard doesn't support'characters to delimit properties and string literals, and so cannot be queried using SQL Server's built-in functions as you're expecting to do.