|
-
Nov 20th, 2001, 01:25 PM
#1
Thread Starter
Fanatic Member
2 ways
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|