troubleshooting Question

Combing ROW_NUMBER() and FOR XML

Avatar of REA_ANDREW
REA_ANDREWFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft SQL Server 2005Microsoft SQL ServerMicrosoft SQL Server 2008
3 Comments1 Solution320 ViewsLast Modified:
Hi,

I am wondering the best way to go about this.  I need to shape data which is returned from SQL Server.  For example:

Return Customer
     Return Customer Orders
          Return Customer Order Items
Return Customer
     Return Customer Orders
          Return Customer Order Items
Return Customer
     Return Customer Orders
          Return Customer Order Items


So eachrecord of a customer also contains there related Orders and subsequently the related order items.

I have opted for the FOR XML AUTO,TYPE  and it is working great for me.  My question is as follows:

How can i combine the ROW_NUMBER() function with this FOR XML AUTO, TYPE,  so in one select statement I will end up with Customer, orders and order items of that customer, but i need to return this data for the customers who are on page 1 with page size of 10.  So 10 customer nodes with the related order and order item collections

TIA

ANDREW
ASKER CERTIFIED SOLUTION
momi_sabag

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros