I have this JSON array, which is stored in an SQL Server table column named [json]
. The table only has this one column.
CREATE TABLE MyTable (
[json] nvarchar(200)
);
INSERT INTO MyTable
VALUES('[{"Id":1},{"Id":2},{"Id":3}]');
db<>fiddle here
Output I need: Each Id in a separate row under the same column using a SELECT statement:
Id (column name)
----------------
1
2
3
What I tried:
SELECT JSON_VALUE([json], '$.Id') as Id
FROM table
But the result was empty:
Id
--------
null