with tb(a,b) as ( select 'a','1' union all select 'a','2' union all select 'a','3' union all select 'b','1' union all select 'b', '2') select A,stuff((select ','+b from tb where A=a.a for xml path('')),1,1,'')as b from tb a group by a
[解决办法] 写个CLR聚合函数就可以了 网上很多例子:如最多的这个STRJOIN就是了 编译一下就可以运行了 using System; using System.Data; using System.Data.SqlClient; using System.Data.SqlTypes; using Microsoft.SqlServer.Server; using System.Text;