为 JSON AUTO
自动将第二个表中的值嵌套为 JSON 对象的嵌套子数组:
SELECT top 5 o.object_id, o.name, c.column_id, c.name
FROM sys.objects o
JOIN sys.columns c ON o.object_id = c.object_id
FOR JSON AUTO
查询的结果将是 JSON 对象的数组:
[
{
"object_id":3,
"name":"sysrscols",
"c":[
{"column_id":12,"name":"bitpos"},
{"column_id":6,"name":"cid"}
]
},
{
"object_id":5,
"name":"sysrowsets",
"c":[
{"column_id":13,"name":"colguid"},
{"column_id":3,"name":"hbcolid"},
{"column_id":8,"name":"maxinrowlen"}
]
}
]