Demonstration of SQL Server 2016 OPEN JSON to convert back JSON to Relational Structure

Rajnilari2015
Posted by Rajnilari2015 under Sql Server category on | Points: 40 | Views : 220
The OPENJSON rowset function converts JSON text into a set of rows and columns. Below is a usage of the same

DECLARE @json NVARCHAR(MAX)

SET @json='[{"SlNo":1,"Name":"Test Name2","MonthName":"MAY 2016"},{"SlNo":2,"Name":"Test Name1","MonthName":"SEP 2014"}]';

SELECT *
FROM OPENJSON(@json)
WITH
(
SlNo INT '$.SlNo' ,
Name varchar(200) '$.Name',
MonthName varchar(200) '$.MonthName'
)

/*

SlNo Name MonthName
1 Test Name2 MAY 2016
2 Test Name1 SEP 2014

*/

Comments or Responses

Login to post response