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)
 Summarize Recordset Query

Author  Topic 

vbc22
Starting Member

4 Posts

Posted - 2006-07-24 : 00:11:02
Hello,

I'm new and would like your help on the following:

Table 1
workOrder (PK), modified, created, user

Table 2
itemID (PK), workOrderID (FK), modified, created, user

Is it possible to write a query that will return a single string to represent the one-to-many itemIDs belonging to a single workOrder?

The end-result recordset I am looking to ascertain is:


workOrder items
w001 i01
w002 i23, i39, i01 <--- multiple items work order
w003 i88


The reason why I am seeking help on this is because I don't want to use the query I presently have that duplicates each work order that has more than one item. Instead, I'd like to be able summarize all the items as a string with the itemID's concatenated, as illustrated above.

Is this possible?

I would really appreciate any solutions or guidance to reference material to solve this problem.

Regards.


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-07-24 : 00:16:06
take a look at here http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx


KH

Go to Top of Page

vbc22
Starting Member

4 Posts

Posted - 2006-07-24 : 00:28:48
quote:
Originally posted by khtan

take a look at here http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx


KH





Thank you very much khtan!

That was what I was looking for. Thanks!

:-)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-07-24 : 11:24:04
Note that if concatenated string exceeds 8000 characters you should use more than one variable. If possible do concatenation in front end application

Madhivanan

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

- Advertisement -