Tuesday, August 3, 2010

Using FOR XML and OPENXML to Publish and Process XML Data

Using FOR XML and OPENXML to Publish and Process XML Data

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