In a previous article I showed how to look at what
query plans are in SQL Server's memory. In this article I'll look at
how they got there and how and when they get reused. This is commonly
called compiling a query plan. More specifically I'll look at how and when
SQL Server can parameterize dynamic SQL to reuse the query plan.
Read Introduction to Parameterization in SQL Server