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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 Using COALESCE to build a comma-delimited string
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

billsox
Yak Posting Veteran

74 Posts

Posted - 02/16/2003 :  08:15:29  Show Profile  Reply with Quote

Hi folks --

I love the SQL Team article on using COALESCE to build comma-delimited strings. Very useful in my work. But I'm running into a situation where I want to use this technique but can't seem to figure out how. Basically, I have a table that looks like this:


Field1 Field2
====== ======
A 1
A 2
A 3
B 1
B 2
B 3
B 4



And I want to be able to create a SELECT statement whose results look like this:


Field1 Field2
====== ======
A 1, 2, 3
B 1, 2, 3, 4



Any ideas on how I can accomplish this?

Thanks in advance.

Bill

robvolk
Most Valuable Yak

USA
15732 Posts

Posted - 02/16/2003 :  08:18:28  Show Profile  Visit robvolk's Homepage  Reply with Quote
There's one or two other articles on how to extend the functionality:

http://www.sqlteam.com/SearchResults.asp?SearchTerms=csv

Go to Top of Page

jsmith8858
Dr. Cross Join

USA
7423 Posts

Posted - 02/16/2003 :  10:06:36  Show Profile  Visit jsmith8858's Homepage  Reply with Quote
Look at Byrmol's post for a neat function idea that's easy to use, efficient, and works in any SELECT statement -- as long as you have SQL 2000:

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

- Jeff
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000