码迷,mamicode.com
首页 > 数据库 > 详细

sql 拼接json

时间:2020-07-06 16:12:33      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:number   sel   top   pat   sele   nbsp   char   weight   The   

select ‘[‘ + STUFF((
select top 10
‘,{"carnumber":"‘ + cast(carnumber as varchar) + ‘"‘
+ ‘,"goodsno":"‘ + cast(goodsno as varchar)+ ‘"‘
+ ‘,"goods":"‘ + cast(Goods as varchar) + ‘"‘
+‘}‘
from OtherWeight t1
for xml path(‘‘),type
).value(‘.‘, ‘varchar(max)‘), 1, 1, ‘‘) + ‘]‘

 

 


select ‘[‘ + STUFF((
select top 10
‘,{"carnumber":"‘ + cast(carnumber as varchar) + ‘"‘
+ ‘,"goodsno":"‘ + cast(goodsno as varchar)+ ‘"‘
+ ‘,"goods":"‘ + cast(Goods as varchar) + ‘"‘
+‘}‘
from OtherWeight t1
for xml path(‘‘)
), 1, 1, ‘‘) + ‘]‘

 

sql 拼接json

标签:number   sel   top   pat   sele   nbsp   char   weight   The   

原文地址:https://www.cnblogs.com/suhq/p/13255125.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!