sql读取数据并返回json
/*
INCLUDE_NULL_VALUES:为空也显示
WITHOUT_ARRAY_WRAPPER:结果集不以数组展示,默认json数组
*/
select top 10 *
from [dbo].student
FOR JSON AUTO, INCLUDE_NULL_VALUES,WITHOUT_ARRAY_WRAPPER
/* 返回主子结构的json数据
*/
select
sex,
json_query((
select name,age,birthday
from dbo.student carsInner
where carsInner.sex=carsOuter.sex
for json path
)) as 人员
from dbo.student carsOuter
group by sex
for json path;