????????

????????????в??????洢?????????????м?????洢??SQLServer????????????С?????????????????Щ????????????????Σ??????Щ????????洢??????????????????????????治?????????????????????????????????2005???????????????????????????????????SQLServer 2008????????????????????????????????????2012???????á???????????????

????????????????????????????к?????????????е???????????????????????????У???????????????????????????????????????

?????????????

???????????????????????????棬?????м?????????????????????

????1????????ж????????????????У?

SELECT  CP.usecounts AS CountOfQueryExecution ??
        CP.cacheobjtype AS CacheObjectType ??
        CP.objtype AS ObjectType ??
        ST.text AS QueryText
FROM    sys.dm_exec_cached_plans AS CP
        CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS ST
WHERE   CP.usecounts > 0
GO

??????????£?

????2??????????????

DBCC FREEPROCCACHE
GO

????3????????????????????????????в???1?е????

???????裺

????1????????????

USE AdventureWorks
GO
SELECT  *
FROM    Sales.SalesOrderDetail
WHERE   SalesOrderDetailID = 43659
GO

????2?????????????????????????м?????棬??????????????????????

SELECT  CP.usecounts AS CountOfQueryExecution ??
        CP.cacheobjtype AS CacheObjectType ??
        CP.objtype AS ObjectType ??
        ST.text AS QueryText
FROM    sys.dm_exec_cached_plans AS CP
        CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS ST
WHERE   CP.usecounts > 0
GO