Skip to content

Instantly share code, notes, and snippets.

@rodolfofadino
Created March 19, 2013 16:13
Show Gist options
  • Save rodolfofadino/5197478 to your computer and use it in GitHub Desktop.
Save rodolfofadino/5197478 to your computer and use it in GitHub Desktop.
query execution count
--DBCC TRACEON(8666)
--GO
SELECT qt.text [Comando],
CP.usecounts [Qtd Executado],
cp.size_in_bytes [TamanhoBytes],
cp.objtype [TipoConsulta],
qp.query_plan [ExecutionPlan]
FROM sys.dm_exec_cached_plans cp
CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) qp
CROSS APPLY sys.dm_exec_sql_text (cp.plan_handle) qt
WHERE qt.text LIKE '%termo%' and qt.text not LIKE '%sys.dm_exec_cached_plans%'
--dbcc freeproccache
--DBCC TRACEOFF(8666)
--GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment