In SQL Server, the FOR XML clause allows us to return the results of a query as an XML document.
When we use this clause, we have various options for how we want to shape the resulting XML document.
Below is an explanation of how the FOR XML clause works, including the basic options we have when using it.