看看这个
第一步
第二步,去除最后一个逗号,整体添加[]
代码
select
'{"ItemName":"' + s_ItemName + '"',
',"Dosage":' + CONVERT(varchar, n_Dosage),
',"DosageUnit":"' + s_DosageUnit + '"},'
from
tAnesthesiaEvent
where
s_ItemClass = 'B'
for xml path('')
--记得去掉最后一个逗号
select '[' + (select left(t.BLODOD_IN_List, LEN(t.BLODOD_IN_List) - 1) from (
select (select '{"ItemName":"' + s_ItemName + '"',
',"Dosage":' + CONVERT(varchar, n_Dosage),
',"DosageUnit":"' + s_DosageUnit + '"},'
from tAnesthesiaEvent
where s_ItemClass = 'B'
and n_DataType= 0
--and s_OMNO = ''
for xml path('')) as BLODOD_IN_List) t
) + ']'