sql server有没有类似sys_connect_by_path的函数
表
A B
1 a
2 b
3 c
想把B字段全部查询出来,得到结果:a,b,c
以逗号分割。
[解决办法]
- SQL code
if not object_id('tb') is null drop table tbGoCreate table tb([A] int,[B] nvarchar(1))Insert tbselect 1,N'a' union allselect 2,N'b' union allselect 3,N'c'GoSelect distinct stuff((select ','+[B] from tb for xml path('')),1,1,'')from tb t/*a,b,c*/