Skip to content

Instantly share code, notes, and snippets.

@veysby
Created March 3, 2015 16:57
Show Gist options
  • Save veysby/9586722a06add9b9548a to your computer and use it in GitHub Desktop.
Save veysby/9586722a06add9b9548a to your computer and use it in GitHub Desktop.
MSSQL: cached query plans
-- DO NOT RUN this script on Production environment
-- Clear the plan cache
dbcc freeproccache
-- Look at the cached query plans
select st.text,*
from sys.dm_exec_cached_plans cp
cross apply sys.dm_exec_sql_text(cp.plan_handle) st
where (st.text like '%select * from Person.Address%')
and st.text not like '%select st.text%'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment