• Also know that the optimizer, with one exception, treats a parameter (before the AS) and a variable (after the AS) differently. A parameter value is known to the optimizer when it compiles the query since the parameter has to be passed with the execution statement, while a variable value is not known (except in the case of a recompile, the one exception). The known values are used to compare against the statistics to arrive at a more specific plan for the data being passed. This process is known as parameter sniffing. A variable, because it's value is unknown, will get an average plan based on an average of the statistics (except, again, in the case of recompiles).

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning