DECLARE @infoParam NVARCHAR(MAX);
DECLARE @items NVARCHAR(MAX);
SET @infoParam='{
"SCHOOL": "某某中学",
"SCHOOLCODE": "1234",
"USER": [{
"userid": "20XX001",
"username": "张三"
}, {
"userid": "20XX002",
"username": "李四"
}, {
"userid": "20XX003",
"username": "熊大"
}, {
"userid": "20XX004",
"username": "熊二"
}]
}'
select @items=JSON_QUERY(@infoParam,'$.USER')
SELECT
JSON_VALUE(VALUE,'$.username') AS 姓名
FROM OPENJSON(@items)
标签:username,拆分,SQLSERVER,userid,JSON,USER,infoParam,items
From: https://www.cnblogs.com/SuSVIP/p/17405606.html