create table tb(UserID int,RoleName nvarchar(10))
insert into tb select 1,'超级管理员'
insert into tb select 1,'管理员'
insert into tb select 2,'管理员'
go
select UserID,stuff((select ','+RoleName from tb where UserID=a.UserID for xml path('')),1,1,'')RoleName from tb a group by UserID
go
drop table tb
/*
UserID      RoleName
----------- --------------------------------
1           超级管理员,管理员
2           管理员

(2 行受影响)
*/

相关文章:

  • 2021-10-18
  • 2021-07-11
  • 2021-10-30
  • 2021-09-15
  • 2022-12-23
  • 2021-12-06
  • 2021-07-20
猜你喜欢
  • 2021-06-09
  • 2021-12-27
  • 2022-12-23
  • 2021-10-13
相关资源
相似解决方案