Databases Reference
In-Depth Information
To show an XML plan you can use the following commands.
SET SHOWPLAN_XML ON
GO
SELECT DISTINCT ( City ) FROM Person . Address
GO
SET SHOWPLAN_XML OFF
Listing 1-2.
This will display a link starting with the following text:
<ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004 ...
Listing 1-3.
Clicking the link will show you a graphical plan, and you can then display the XML plan
using the same procedure as explained earlier. Alternatively, you can use the following
code to display a text execution plan.
SET SHOWPLAN_TEXT ON
GO
SELECT DISTINCT ( City ) FROM Person . Address
GO
SET SHOWPLAN_TEXT OFF
GO
Listing 1-4.
This code will actually display two results sets, the first one returning the text of the
T-SQL statement. In the second result set, you will see the following plan (edited to fit the
page), which shows the same Hash Aggregate and Index Scan operators displayed earlier
in Figure 1-2.
Search WWH ::




Custom Search