1. Using a cursor
2. With no cursor

1.
declare alltogether cursor for
select id from test

declare @concatenatevals varchar(4000)
set @concatenatevals = ' '
declare @ID int

open alltogether
fetch next from alltogether into @ID
while (@@Fetch_Status = 0)
begin
set @concatenatevals = @concatenatevals + ' ' + convert(varchar(10),@ID)
fetch next from alltogether into @ID
end


print @concatenatevals
close alltogether
deallocate alltogether

2.

declare @moi varchar(255)
select @moi = ' '
SELECT @moi = COALESCE(@moi + convert(varchar(10),id), " ") + " "
FROM test
print @moi


granted I may have a little extra in the second solution
Thanks