Skip to content

Instantly share code, notes, and snippets.

@jdaigle
Created September 24, 2014 15:16
Show Gist options
  • Save jdaigle/2fbfb232475f31b6f393 to your computer and use it in GitHub Desktop.
Save jdaigle/2fbfb232475f31b6f393 to your computer and use it in GitHub Desktop.
Evict SQL Query Plan
SELECT [text], cp.size_in_bytes, plan_handle
FROM sys.dm_exec_cached_plans AS cp
CROSS APPLY sys.dm_exec_sql_text(plan_handle)
WHERE cp.cacheobjtype = N'Compiled Plan'
AND cp.objtype = N'Adhoc'
AND cp.usecounts = 1
ORDER BY cp.size_in_bytes DESC;
DBCC FREEPROCCACHE(plan_handle)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment