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)
 String concatenation in MS SQL server

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-09-23 : 07:28:38
Frank writes "Hi, I have a question regarding how to merge information in records together in SQL server. The table itself contains many-to-many relationship such as Employee table. One employee as a boss can have multiple subsidaries. And one employee can report to more than one boss.

So how can i generate a derived table contains that all employees name related with a particular employee in one records. such as

Employee Related
------------------------------------
David John, Beth, Cathy


I have a Store procedure using two level nested Cursors for this. But it is extremely slow.

I am using SQL 2000. I understand that in SQL 2005 I can create my own UDF aggregates so that I can use the group by to solve this. But it is for SQL 2000.

Thanks in advance

-Frank"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-23 : 07:33:04
See if this helps you
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true

Madhivanan

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

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-09-23 : 07:35:00
quote:
And one employee can report to more than one boss
"I have 8 different bosses right now..."
"Eight?"
"Eight, Bob. So that means when I make a mistake, I have eight different people coming by to tell me about it."

I love Office Space:

http://www.imdb.com/title/tt0151804/

Anyway, here's a technique that should do the trick for you:

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

And we have a few more articles on CSV stuff:

http://www.sqlteam.com/searchresults.asp?SearchTerms=csv
Go to Top of Page
   

- Advertisement -