I'm trying to create the below XML doc from a sql 2005 query. What I'm struglling with is the doc has 3 nodes on the same level - Customer, RepairFacility, and Action.
--What is needed
<Elements>
<Element>
<Customer>
<FirstName></FirstName>
<LastName></LastName>
</Customer>
<RepairFacility>
<LocationName></LocationName>
<LocationPhone></LocationPhone>
</RepairFacility>
<Action>
<FollowUpFlag></FollowUpFlag>
<DateAction></DateAction>
</Action>
</Element>
<Element>
</Element>
</Elements>
--My Query
SELECT
( SELECT .....
FROM tbl A1
FOR XML PATH('Customer'), TYPE ),
( SELECT ......
FROM tbl A2
FOR XML PATH('RepairFacility'), TYPE),
( SELECT .....
FROM tbl J
FOR XML PATH('Action'), TYPE )
FOR XML PATH(''), ROOT('Element')
--What I get
<Elements>
<Element>
<Customer>
<FirstName></FirstName>
<LastName></LastName>
</Customer>
<Customer>
<FirstName></FirstName>
<LastName></LastName>
</Customer>
<RepairFacility>
<LocationName></LocationName>
<LocationPhone></LocationPhone>
</RepairFacility>
<RepairFacility>
<LocationName></LocationName>
<LocationPhone></LocationPhone>
</RepairFacility>
<Action>
<FollowUpFlag></FollowUpFlag>
<DateAction></DateAction>
</Action>
<Action>
<FollowUpFlag></FollowUpFlag>
<DateAction></DateAction>
</Action>
</Element>
<Element>
</Elements>
I'm grateful for any help.