这将为您提供以逗号分隔的列表中的值列表
create table #temp( y int, x varchar(10))insert into #temp values (1, 'value 1')insert into #temp values (1, 'value 2')insert into #temp values (1, 'value 3')insert into #temp values (1, 'value 4')DECLARE @listStr varchar(255)SELECt @listStr = COALESCE(@listStr+', ', '') + xFROM #tempWHERe #temp.y = 1SELECT @listStr as Listdrop table #temp



