有谁知道将遗留展示计划文本转换为图形格式的方法吗?
换句话说,我可以获取从 SET SHOWPLAN_TEXT ON 返回的 StmtText 并将其转换为显示图形执行计划吗?我是否需要将其解析为 XML 和 .sqlplan 格式才能查看图表?
Eric:,这里是例子,针对 AdventureWorks 运行:
SET SHOWPLAN_TEXT ON
GO
SELECT c.CustomerID, soh.ShipDate
FROM Sales.SalesOrderDetail sod
INNER JOIN Sales.SalesOrderHeader soh ON sod.SalesOrderID = soh.SalesOrderID
INNER JOIN Sales.Customer c ON c.CustomerID = soh.CustomerID
WHERE sod.SpecialOfferID = 2
AND soh.ShipDate between '2003-01-01 00:00:00.000' and '2004-01-01 00:00:00.000'
AND c.CustomerType = 'I'
你会看到这个 StmtText 返回:
StmtText
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|--Hash Match(Inner Join, HASH:([soh].[CustomerID])=([c].[CustomerID]))
|--Hash Match(Inner Join, HASH:([sod].[SalesOrderID])=([soh].[SalesOrderID]))
| |--Index Seek(OBJECT:([AdventureWorks].[Sales].[SalesOrderDetail].[ix_nc_SpecialOfferID_inc_SalesOrderID] AS [sod]), SEEK:([sod].[SpecialOfferID]=(2)) ORDERED FORWARD)
| |--Index Seek(OBJECT:([AdventureWorks].[Sales].[SalesOrderHeader].[ix_nc_ShipDate_inc_SalesOrderID_CustomerID] AS [soh]), SEEK:([soh].[ShipDate] >= '2003-01-01 00:00:00.000' AND [soh].[ShipDate] <= '2004-01-01 00:00:00.000') ORDERED FORWARD)
|--Index Seek(OBJECT:([AdventureWorks].[Sales].[Customer].[ix_nc_CustomerType] AS [c]), SEEK:([c].[CustomerType]=N'I') ORDERED FORWARD)