Question

I've looked all over for this command....what's the command to reset the SQL Server's execution plan?

Was it helpful?

Solution

For clarity..........

Executing sp_recompile will "mark" the given stored procedure for recompilation, which will occur the next time it is executed.

Using the WITH RECOMPILE option will result in a new execution plan being generated each time the given stored procedure is executed.

To clear the entire procedure cache execute

DBCC FREEPROCCACHE

OTHER TIPS

For stored procedures, you use the WITH RECOMPILE option.

If you want to reset QEP for a stored procedure, you shall use sp_recompile

It's not entirely clear from your question what you're after. But in addition to the other suggestions, DBCC FREEPROCCACHE clears all cached execution plans.

sp_recompile will dump the existing query plan and recompile the procedure. Or you can restart SQL and that will clear the entire execution plan cache.

WITH RECOMPILE is going to generate a new plan EVERY time you execute it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top