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
 Transact-SQL (2000)
 Return comma seperated values in a row

Author  Topic 

Nightfall
Starting Member

3 Posts

Posted - 2008-07-02 : 10:13:21
Hello all. I have a T-SQL problem which I will try to describe as best as I can.

tblPerson
-------
columns: id,name
data: 1, John
2,Alex
3,Gus

tblnationality
-------------
columns: id,nationality
data: 101,Greek
102,Italian
103,Spanish

tblPersonid_to_nationalityId
-------
columns: personID,nationalityid
data: 1,101
1,102
2,103
3,101

That means that a person can have 2 nationalities. I want my end result to be like this

John | Greek,Italian
Alex | Spanish
Gus | Greek

The first column will contain the Person's name and the second the person's nationalities comma separated.

Any ideas ? Thanks in advance !

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-07-02 : 10:29:22
Always try a simple google search, first:

http://www.google.com/search?q=sql+server+Return+comma+separated+values+in+a+row

The subject you used for this topic contains all the key terms you need if you just add the words "sql server". Lots and lots of results and ideas are returned.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -