;with xmlnamespaces ('urn:schemas-microsoft-com:datatypes' as dt) select prsn.FirstName As [CustomerInfo/FirstName], prsn.LastName As [CustomerInfo/LastName], soh.SalesOrderNumber As [OrderHdrInfo/SalesOrderNo], soh.TotalDue As [OrderHdrInfo/TotalDue], addr.AddressLine1 As [ShipToInfo/ShipToAddr1], addr.City As [ShipToInfo/ShipToCity], ( select top 3 prod.[Name] as [OrderDtlItem/ProductName], s.LineTotal as [OrderDtlItem/LineTotal] from Production.Product prod inner join Sales.SalesOrderDetail s on prod.ProductID = s.ProductID where s.SalesOrderID = soh.SalesOrderID for xml path(''), root('OrderDtlItems'), type ), addr.AddressLine1 As [ShipToInfo/ShipToAddr1], addr.City As [ShipToInfo/ShipToCity] from Person.Person prsn inner Join Sales.Customer cust on prsn.BusinessEntityID = cust.PersonID inner Join Sales.SalesOrderHeader soh on cust.CustomerID = soh.CustomerID inner Join Person.[Address] addr on soh.ShipToAddressID = addr.AddressID inner Join Person.StateProvince sp on addr.StateProvinceID = sp.StateProvinceID where prsn.BusinessEntityID = 1045 and soh.SalesOrderID = 43659 for xml path('CustomerOrder');The above returns the shape you need: James Hendergart SO43659 23153.2339 42525 Austell Road Austell Mountain-100 Black, 42 2024.994000 Mountain-100 Black, 44 6074.982000 Mountain-100 Black, 48 2024.994000 42525 Austell Road Austell Hope this helps. Oleg
9 People are following this question.