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)
 Return all records from grouped resultset into single record

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-07-11 : 11:26:19
Mark writes "I have a recordset with a single common field which can be grouped.

I would like to return a single record based on the grouped field which contains a varchar or memo field with the data from all the records concatonated into it. Preferably in the form of a view which I can use with other views

ex data:
Item PO Site Qty
00615 PO00S0924 KP 600
00615 PO00F925 WA 240
00616 PO00F925 WA 480
00616 PO00S0924 KP 2400
00618 PO00S0924 KP 300
00618 PO00F925 WA 60

Desired result:

Item Orders
00615 PO00S0924-KP-600,PO00F925-WA-240
00616 PO00F925-WA-480,PO00S0924-KP-2400
00618 PO00S0924-KP-300,PO00F925-WA-60

Thanks,

Mark"

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2006-07-11 : 11:35:32
This is a common type of question. And this is a common reference:

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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-07-12 : 02:34:45
Also note that if the concatenated strings exceeds 8000 characters you may need to use more than one variable to have strings. If possible do concatenation at front end application

Madhivanan

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

haw001
Starting Member

20 Posts

Posted - 2006-07-12 : 17:06:00
Thanks, I managed to get an answer with some great help from the forum.

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

Thanks,

Mark
Go to Top of Page
   

- Advertisement -