2016 伎 覯 json 讌 . 豢 企蟆 襷る . json企 xml企 襦讌 螳.
--一危 襷り鍵
--drop table #temp
select N'A' 蠏碁9, N'1' 螳 into #temp union all
select N'A' 蠏碁9, N'2' 螳 union all
select N'A' 蠏碁9, N'3' 螳 union all
select N'B' 蠏碁9, N'100' 螳 
go

--譟壱
declare @json nvarchar(4000)

select 
    @json = isnull(@json, '') + ',' + quotename(蠏碁9, '"') + ':' + 
        '[' + quotename(stuff((select ',' + cast(螳 as nvarchar(4000)) as 'text()' from #temp where a.蠏碁9 = 蠏碁9 for xml path('')),1,1,''), '"') + ']'
from (select distinct 蠏碁9 from #temp) a

select convert(nvarchar(100), '{' +  stuff(@json, 1, 1, '') + '}') json


/* 蟆郁骸
json
----------------------------------------------------------------------------------------------------
{"A":["1,2,3"],"B":["100"]}
*/