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)
 Concatinating all rows into a single field

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-04-22 : 08:02:30
David writes "Sorry for the confusing title, but i really don't know how to expaling this simply. Basically i have one table [vehicles] which holds information against a vehicle, and a second table [options] which hold the optional features for a given vehicle. A simple 1-to-many association.

What i want to do, is to select the on the first table, but instead of returning muliple row
--
Select * from [vehicles] a
inner join [options] b on a.VID = b.VID

VEHICLE 1 | REGPLATE | OPTION1
VEHICLE 1 | REGPLATE | OPTION2
VEHICLE 1 | REGPLATE | OPTION3


what i would like to return is

VEHICLE 1 | REGPLATE | OPTION1,OPTION2,OPTION3

i have consided using a while loop, and a cursor. but before i did this i thought i would check to see whether there is abuilt in function or not.

thankyou in advance"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-04-22 : 08:03:51
Yep, take a look at these articles:

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

Someone has posted a user-defined function for this, check the Script Library:

http://www.sqlteam.com/forums/forum.asp?FORUM_ID=11
Go to Top of Page
   

- Advertisement -