我想让SQL Server 2012/2014查询返回以下JSON输出。
在每个JSON对象中都有内部数组。我正在寻找一种方法来实现相同的目标。如下所示,Details和Summary是数组,并且具有多个键值对。
我首先应该尝试创建XML并将其解析以将其转换为JSON。这是我第一次在SQL上处理XML / JSON数据。
[
{"date": "2018-11-09 18:30:00",
"details": [{
"ServerName":"Server1",
"ScheduleStart":"2018-11-09 08:00:00",
"ScheduleEnd": "2018-11-09 11:00:00"
},
{
"ServerName":"Server2",
"ScheduleStart":"2018-11-09 18:00:00",
"ScheduleEnd": "2018-11-09 21:00:00"
},
{
"ServerName":"Server3",
"ScheduleStart":"2018-11-09 21:00:00",
"ScheduleEnd": "2018-11-10 00:00:00"
}
],
"total":3,
"summary":[{
"ServerName": "Server1",
"Status": "Success"
},
{
"ServerName": "Server2",
"Status": "Failed"
},
{
"ServerName": "Server3",
"Status": "Scheduled"
}
]
},
]