1、
declare @sql as varchar(8000) select @sql='' Select @sql=@sql+UserName【字段名】+',' from dbo.b_NewGrant【表名】 select @sql
2、
declare @mytable table (Col1 varchar(10)) insert into @mytable values ('AA'),('BB'),('CC') declare @Colstring varchar(50) select @Colstring = isnull(@Colstring+',' , '' ) + isnull( Col1 , '' ) from @mytable select @Colstring as Colstring