Hi I have a simple question. But it lead to another question. I want to delete the query plan for a stor proc i ran. So I ran the proc using
exec dbo.uspNameOfProc
and then checked the plan chace using the query
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 [text] like '%uspNameOfProc%'
what else am i missing?
RUN
exec dbo.uspNameOfProcThen Run sp_who3 Find out which spid it is running under.This will get you the Plan handle. To see the execution plan run.
Then if you wish to clear the plan from cache use this.
Hope that helps.
UPDATE***
Make sure perform these operations on separate query windows so as to not alter the execution plan.