this will give you the list of values in a comma separated list
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+', ', '') + x
FROM #temp
WHERE #temp.y = 1
SELECT @listStr as List
drop table #temp
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…