这个场景很常见,在网上查了一下,人家说用xpath 方法,亲测有效。

 

	select stuff(
	(select ','+cast(u.UserName_Chn as varchar(max)) from BO_ManagementPeo b inner join V_P_UserInfo
	u on u.UserGUID = b.UserGUID where a.ObjectGUID=b.ObjectGUID for xml path(''))
	,1,1,'') as JoinUsers, ObjectGUID
	from BO_ManagementPeo a
	group by ObjectGUID

  

如果只是单个

select a.*,
stuff(
(select ','+cast(FullName as varchar(max)) from  erp.dbo.yx_khinfo where CHARINDEX('首利', FullName) > 0 for xml path(''))
,1,1,'') fullname
from (select '首利' col1) a

  

相关文章:

  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2021-12-27
猜你喜欢
  • 2021-05-28
  • 2021-09-07
  • 2021-12-27
  • 2022-12-23
  • 2021-09-13
  • 2021-07-16
相关资源
相似解决方案