30.06.2013 Views

SQL Server Execution Plans - Red Gate Software

SQL Server Execution Plans - Red Gate Software

SQL Server Execution Plans - Red Gate Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 7: Special Datatypes and <strong>Execution</strong> <strong>Plans</strong><br />

ON p.BusinessEntityID = e.BusinessEntityID<br />

INNER JOIN Person.BusinessEntityAddress AS bea<br />

ON e.BusinessEntityID = bea.BusinessEntityID<br />

INNER JOIN Person.Address a<br />

ON bea.AddressID = a.AddressID<br />

FOR XML AUTO;<br />

Listing 7.1<br />

This generates the actual execution plan shown in Figure 7.1.<br />

Figure 7.1<br />

The difference between this execution plan and that for any "normal" query may be<br />

hard to spot. It's at the very beginning of the logical processing order. Instead of a<br />

T-<strong>SQL</strong> Select operation, we see an XML Select operation. That is the only change.<br />

Otherwise, it's simply a query.<br />

To see all the various methods at work, instead of the slightly complicated example above,<br />

consider the second, somewhat simpler, query in Listing 7.2. We'll compare the output of<br />

this query using the various FOR XML modes, starting over again with AUTO mode.<br />

258

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!