After covering the XML features included with SQL Server 2005, discussing SELECT ... FOR XML queries is somewhat anticlimactic. I’ve included the information here for developers who are still using SQL Server 2000 in their applications and therefore can’t use SQL Server 2005’s XML features.
The simplest way to execute such a query and examine the results is to execute the query in SQL Server Query Analyzer. Let’s take a simple query that retrieves the values of the CustomerID and CompanyName columns for the first two rows in the Customers table:
SELECT TOP 2 CustomerID, CompanyName FROM Customers
And then let’s append the ...