Description : In this post how to parse json data in MS SQL using OPENJSON first we need json here declare one json variable and set static json in this variable. write one select querye with OPENJSON for convert json to SQL Table
DECLARE @json NVARCHAR(MAX)
SET @json =
N'[
{ "name": "Test 1", "surname": "Testing" },
{ "name": "Test 2", "surname": "Testing Again" }
]'
SELECT * FROM OPENJSON(@json)
WITH (
FirstName nvarchar(50) '$.name'
, LastName nvarchar(50) '$.surname'
)
Below screen shot display how to write query of OPENJSON
Below screen shot display how result look like
DECLARE @json NVARCHAR(MAX)
SET @json =
N'[
{ "name": "Test 1", "surname": "Testing" },
{ "name": "Test 2", "surname": "Testing Again" }
]'
SELECT * FROM OPENJSON(@json)
WITH (
FirstName nvarchar(50) '$.name'
, LastName nvarchar(50) '$.surname'
)
Below screen shot display how to write query of OPENJSON
Below screen shot display how result look like
No comments:
Post a Comment