SQLServer 多行数据的一个字段内容合并成一个
select djid, pxId,
JgmData = (substring((select ‘,‘ + JgmData
from D_Gsp_HqJgm where DjId = a.DjId and PxId = a.PxId
for xml path(‘‘)),2,9999))
from (select distinct djId,pxId from D_Gsp_HqJgm ) a
for xml path:它就是将查询结果集以XML形式展现,有了它我们可以简化我们的查询语句实现一些以前可能需要借助函数活存储过程来完成的工作。
相关推荐
gaozhennan 2020-08-16
奎因amp华洛 2020-07-26
sui 2020-06-10
huanghan 2020-06-07
LzHeng 2020-06-05
maokaijiang 2020-06-05
FightFourEggs 2020-05-31
blncle 2020-05-28
踩风火轮的乌龟 2020-05-28
crowds 2020-05-06
blncle 2020-05-06
sui 2020-04-29
maokaijiang 2020-04-18
blncle 2020-04-08
maokaijiang 2020-03-27
blncle 2020-03-20