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
 General SQL Server Forums
 New to SQL Server Programming
 Is it possible to create a Comma Seperated Field?

Author  Topic 

CLEE25
Starting Member

14 Posts

Posted - 2010-03-18 : 09:07:44
Hi all,

I am working on a stored procedure that needs to push an array of interests to another site.

The format I need is:

NAME | EMAIL | INTERESTS
John | Smith | Cats,Dogs,Alligators
Dave | Jones | Cats,Pigs
Bill | Davis | Cats

Currently I have my Procedure outputting

NAME | EMAIL | INTERESTS
John | Smith | Cats
John | Smith | Dogs
John | Smith | Alligators
Dave | Jones | Cats
Dave | Jones | Pigs
Bill | Davis | Cats

So, it there anyway to take those fields and combine them in a comma seperated field so instead of 6 records, I would only have three.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-03-18 : 09:09:11
If you use version 2005 or more, use
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-03-18 : 09:24:10
also try

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

Vaibhav T
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-03-18 : 10:31:15
quote:
Originally posted by vaibhavktiwari83

also try

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

Vaibhav T


Your method may take more time than For XML

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

CLEE25
Starting Member

14 Posts

Posted - 2010-03-18 : 11:00:54
Many thanks to you both for the answer and the fast reponse!
Go to Top of Page
   

- Advertisement -