- The schema of regular tables, temporary tables, or views referred to in the stored procedure statement have changed. Schema changes include changes to the metadata of the table or the indexes on the table.
- Bindings (such as defaults) to the columns of regular or temporary tables have changed.
- Statistics on the table indexes or columns have changed past a certain threshold.
- An object did not exist when the stored procedure was compiled, but it was created during execution. This is called deferred object resolution.
- SET options have changed. (
SET NOCOUNT doesn’t cause stored procedure recompilation)
- The execution plan was aged and deallocated.
- An explicit call of
sp_recompile on a table, view, trigger or stored procedure
- There was an explicit use of the RECOMPILE hint:
CREATE PROCEDURE <spName> WITH RECOMPILE => prevents the caching of the stored procedure plan
EXEC <spname> WITH RECOMPILE; => a new plan is generated temporarily, without being cached of affecting any other existing cached plan
OPTION (RECOMPILE)</sql> => causes statement recompilation