需要寫一個聚合函數create function fn_cmb(@id varchar(100)) returns varchar(8000) as begin declare @s varchar(8000) select @s = isnull(@s, '') + ',' + called from conf where id = @id set @s = stuff(@s, 1, 1, '') return @s end然後調用函數 select fn_cmb(id) from conf group by id
returns varchar(8000)
as
begin
declare @s varchar(8000)
select @s = isnull(@s, '') + ',' + called
from conf
where id = @id set @s = stuff(@s, 1, 1, '') return @s
end然後調用函數
select fn_cmb(id) from conf group by id