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)
 add up strings

Author  Topic 

ygeorge
Yak Posting Veteran

68 Posts

Posted - 2004-03-12 : 14:58:35
Hi,

I have a table for users name, the data is like this -

UserID Name Department

1 Tom A
2 Sandy A
3 James B
4 Chris A
...

I want to add up the names for department A and get a result like this -

'Tom, Sandy, Chris, ...'


Is there an option out there, except for by using cursor, to carry it out? Is it possible to do it with one single query?

Thanks in advance,

George

X002548
Not Just a Number

15586 Posts

Posted - 2004-03-12 : 15:04:24


http://www.sqlteam.com/item.asp?ItemID=2368



Brett

8-)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-03-12 : 15:06:41
There is an article here about putting rows into a comma separated list. Search the articles for csv.

Tara
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-03-12 : 15:09:48
Dang, machine is slow right now that even I got sniped. Who would have thought?!

Tara
Go to Top of Page

ygeorge
Yak Posting Veteran

68 Posts

Posted - 2004-03-12 : 15:19:38
Got it. Thanks alot.

George

quote:
Originally posted by X002548



http://www.sqlteam.com/item.asp?ItemID=2368



Brett

8-)

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-03-12 : 15:23:12
quote:
Originally posted by tduggan

Dang, machine is slow right now that even I got sniped. Who would have thought?!

Tara



Snipage...

I'm about to fall asleep at my desk......


zzzzzzzzzzzzzzzzzzzzz




Brett

8-)
Go to Top of Page
   

- Advertisement -