使用 FOR JSON 将查询结果格式化为 JSON
输入表数据(人员表)
ID |
Name | 年龄 |
---|---|---|
1 |
约翰 | 23 |
2 |
简 | 31 |
询问
SELECT Id, Name, Age
FROM People
FOR JSON PATH
结果
[
{"Id":1,"Name":"John","Age":23},
{"Id":2,"Name":"Jane","Age":31}
]
输入表数据(人员表)
ID |
Name | 年龄 |
---|---|---|
1 |
约翰 | 23 |
2 |
简 | 31 |
询问
SELECT Id, Name, Age
FROM People
FOR JSON PATH
结果
[
{"Id":1,"Name":"John","Age":23},
{"Id":2,"Name":"Jane","Age":31}
]