通过函数实现 CREATE function [dbo].[f_union1](@department nvarchar) returns varchar(8000) as begin declare @ret varchar(8000) set @ret = '' select @ret = @ret+ ','+ 要合并的列字段 from 表名 where 字段名= @department set @ret = stuff(@ret,1,1, ' ') --print(@ret) IF @ret <> ' ' BEGIN set @ret = substring(@ret , 2 , len(@ret)) END return @ret end select * , dbo.f_union1(查询值)carno from 表名