How to nest XML output in a SQL SELECT statement

A customer asked, “How to format [or structure] XML Output to include a sub-group inside the XML”. The customer is using a SELECT statement with FOR XML, and wants to nest an XML element such as the following: Before <BusinessPartner>     <Key>1234</Key>     <Name>Test Company</Name>   </BusinessPartner> After <BusinessPartner>     <Key>1234</Key>     <CompanyDetails>           <Name>Test…

1