Query Plan Different When Using Compiled Values I have pulled out an execution plan from the plan cache and from the XML pulled out the compiled values. Then I have run the query in SSMS using the compiled values and the query plans are different even though they run against the same database.

Can anybody please explain why this occurred?
Most likely, either:


The state of the database (e.g. statistics) changed since the cached plan was first compiled, causing a recompilation; or
Your SSMS connection uses different settings (e.g. ANSI_NULLS) from those used by the connection that cached the plan (so it could not be reused); or
It was an ad-hoc batch and the text of your query did not exactly match the cached version
You used literal values where the original plan was parameterized