Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Store in single variable this 5 rows of record?

Author  Topic 

jonasalbert20
Constraint Violating Yak Guru

300 Posts

Posted - 2004-12-19 : 20:26:04
I have this querry!

Select * from tbl
result is....

ID----------> Name
1234--------> Jonas Albert
2222--------> Ian Datang
1554--------> Fitz Lantape


now i want to store this returned data in a single variable named @AC.
Result shoul be this....

select @AC

------------------------------
Jonas Albert -- Ian Datang -- Fitz Lantape

How should this be done?



Want Philippines to become 1st World COuntry? Go for World War 3...

nr
SQLTeam MVY

12543 Posts

Posted - 2004-12-19 : 21:12:23
declare @ac varchar(1000)
select @ac = coalesce(@ac + ' -- ', '') + name
from tbl
select @ac


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jonasalbert20
Constraint Violating Yak Guru

300 Posts

Posted - 2004-12-19 : 21:46:38
tnx nr...

Want Philippines to become 1st World COuntry? Go for World War 3...
Go to Top of Page
   

- Advertisement -