Skip to content

Instantly share code, notes, and snippets.

@robsonalves
Last active October 21, 2015 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robsonalves/69d389f57925cb217d63 to your computer and use it in GitHub Desktop.
Save robsonalves/69d389f57925cb217d63 to your computer and use it in GitHub Desktop.
Retorna os planos de execução em cache
set transaction isolation level read uncommitted
SELECT TOP 20
st.text as [SQL]
, cp.cacheobjtype
, cp.objtype
, COALESCE(DB_NAME(st.dbid), db_name(cast(pa.value as int))+ '*', 'Resource') as DataBaseName
, cp.usecounts as [Plan Usage]
, qp.query_plan
from sys.dm_exec_cached_plans cp
cross apply sys.dm_exec_sql_text(cp.plan_handle) st
cross apply sys.dm_exec_query_plan(cp.plan_handle) qp
cross apply sys.dm_exec_plan_attributes(cp.plan_handle)pa
where pa.attribute = 'dbid'
and st.text like '%PartyType%'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment