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)
 Transform rows to Comma-delimited text-field

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-02-18 : 09:22:43
Lars writes "Hi,

Can you solve this tricky question:

I have two tables joined together:


tblcars:
carid Carname
1 Car1
2 Car2
3 Car3

tblAccesories:
AccID CarID AccName
1 1 Acc1
2 1 Acc2
3 2 Acc3



I need ONE select-statement to give the following recordset output:

carid Carname CarAcc
1 Car1 Acc1, Acc2
2 Car2 Acc3
3 Car3 NULL

Can this be done?"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-02-18 : 10:06:54
You can't quite do it with a single SELECT statement, but there's a couple methods described here that are good enough:

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

Go to Top of Page
   

- Advertisement -