Tuesday, August 3, 2010

How to execute SQL queries to return results as XML instead of standard rowsets

USE AdventureWorks2008R2 GO SELECT Cust.CustomerID,         OrderHeader.CustomerID,        OrderHeader.SalesOrderID,         OrderHeader.Status FROM Sales.Customer Cust  INNER JOIN Sales.SalesOrderHeader OrderHeader ON Cust.CustomerID = OrderHeader.CustomerID FOR XML AUTO, ELEMENTS