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)
 Combining multiple rows into single row

Author  Topic 

craft
Starting Member

1 Post

Posted - 2006-06-19 : 11:03:52
Hello,

I want to combine the results of SQL query into a single row; and all results as coma seperated values.

example

Table 1
=======

AID KEY
---------
1 A
1 B
2 C
2 D
3 E


TABLE 2
=======
AID KEY1
----------
1 G
1 H
2 I
3 J
3 K
3 L

REQUIRED RESULT
===============
AID DATA
-------------
1 A,B,G
2 C,D,I
3 E,K,L


Can anyone guide me how to achieve this.

Regards

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2006-06-19 : 13:18:58
What happened to H and J?

Maybe you want to union tables 1 and 2 together and then use this...
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx



Ryan Randall
www.monsoonmalabar.com London-based IT consultancy

Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page
   

- Advertisement -