>Hi All,
>
>I have the OfferHeader and OfferDetail tables in a 1 to many relationship.
>
>OfferHeader:
>Batch
>12345
>67890
>
>
>OfferDetail:
>Batch EDP IsMainStock
>12345 95 1
>12345 96 0
>12345 97 0
>12345 98 0
>67890 85 0
>67890 86 1
>67890 87 0
>
>How can I structure a query to get the following result? Do I have to use a cursor or is there another way for example using PIVOT feature?
>
>
>Result
>Batch MainStockEDP ChildEDPs
>12345 95 96|97|98
>67890 86 85|87
>
>
>Thank you,
>Daniel
Wow, perfect timing. There was a thread yesterday on a similar question in APS.NET forum / SQL Server
See this link
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true which I put in favorites from that thread (need to search for it).
If it's not broken, fix it until it is.
My Blog