Forced Parameterization

In SQL Server 2008, if a SQL statement is executed without parameters, the Query Optimizer parameterizes the statement internally to increase the possibility of matching it against an existing execution plan. This process is called simple parameterization, sometimes referred to as auto-parameterization. Simple parameterization is somewhat limited in that it can parameterize only a relatively small number of queries that match a small number of very simple and strictly defined query templates. For example, simple parameterization is not possible for queries that contain any of the following query elements:

• References to more than one table

IN clauses or OR expressions

UNION

• Any query hints

DISTINCT

TOP

• Subqueries ...

Get Microsoft® SQL Server 2008 R2 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.