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
 SQL Server Development (2000)
 Help with select statement...

Author  Topic 

cbrinson
Starting Member

36 Posts

Posted - 2002-04-10 : 18:14:07
Given the following data set:
Category Name
0 Joe
0 Nick
0 Frank
1 Fred
1 Jim
...

Is it possible to select a comma separated list of Names as a column in the recordset? For example:
0 Joe, Nick, Frank
1 Fred, Jim

I have needed to do this pretty often. Now I just select the data using something like:
SELECT category,name
ORDER BY category ASC

and then use Do While code on the ASP to display it the way I want to. But if there were a quick way of doing this with SQL that would be nice.

Thanks,
Chris

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-04-10 : 18:40:45
You can try Garth's article:

http://www.sqlteam.com/item.asp?ItemID=2368

And this might help too:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=9978

Go to Top of Page

cbrinson
Starting Member

36 Posts

Posted - 2002-04-10 : 22:24:12
Thanks. I would imagine creating a temp table etc. would not be any faster than just looping through the array in asp and writing it to the page. That is the most difficult thing for me. Trying to figure out which solution would be faster while not spending what little time I have constantly testing different scenarios.

Thanks,
Chris

Go to Top of Page

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2002-04-10 : 22:27:22
Chris,

A good rule of thumb is that if it used for presentation then do it at the front end.

HTH

DavidM

Tomorrow is the same day as Today was the day before.
Go to Top of Page
   

- Advertisement -