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)
 Concatenating Multiple rows into a single row

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-05-15 : 10:27:50
Anik writes "Hi,
I don't want to use Cursors or Temporary tables...can I do the following

table_1
Col_1 col_2
1 AA
1 AC
2 AB
3 AA
4 AB
4 AC
...

Table_2
Col_1 Col_2
AA ONE
AB TWO
AC THREE

EXPECTED RESULTSET

Col_1 COl_2 Col_3
1 AA,AC One AND THREE
2 AB TWO
3 AA ONE
4 AB,AC TWO AND THREE

Thanks in advance
Anik"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-05-15 : 11:27:20
There's Garth's article on building strings:

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

There's also some stuff here:

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

And here too:

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

You CANNOT do it in one SELECT statement however, so you'll need to use some kind of intermediate table to build the results into. There's nothing wrong with using a temp table for this purpose.

Go to Top of Page
   

- Advertisement -