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)
 Aggregate text concatenation

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-03-10 : 09:17:18
Matt writes "Several times in my short database career I've run into a situation in which a recordset contains multiple records per key, because multiple values are associated with each key. For instance:


cust_id invoice_num
123 123_345
123 123_598
123 123_089
456 456_567
456 456_987

and what I really wanted was...

cust_id invoice_num
123 123_345, 123_598, 123_089
456 456_567, 456_987


If the values were numbers, you could get a sum of the numbers for each key, but I don't know a way to "sum" the text by concatenating it.

There is usually some programming involved in converting the data from one format to another, and then you don't have a nice recordset to work with. Is there any way to do it with SQL?

Thanks."
   

- Advertisement -