Does altering a stored procedure expire cached execution plans?

Kane picture Kane · Sep 6, 2011 · Viewed 7k times · Source

Does executing a ALTER PROCEDURE statement for a stored procedure cause all cached execution plans for that stored procedure to become invalid and expire in SQL Server 2008 / 2005?

Answer

Martin Smith picture Martin Smith · Sep 6, 2011

Yes.

You can verify this by doing

SELECT * FROM sys.dm_exec_procedure_stats 
where object_id = object_id('YourProc', 'P')

before and after.

From TechNet

[situations in which plans would be removed from cache include] global operations like running DBCC FREEPROCCACHE to clear all plans from cache, as well as changes to a single procedure, such as ALTER PROCEDURE, which would drop all plans for that procedure from cache.