• When you use a local variable, SQL has to estimate the selectivity of the 'where' clause, because it doesn't know the value of the variable when it optimizes the query. If you hard code the value, this problem goes away. If you look at the estimated rows for tblData in both execution plans, you'll see that the counts vary between the 2 plans and a different index is used in each case; this is probably what's causing the discrepancy in query times.

    Have a look at 'Compile-Time Expression Evaluation for Cardinality Estimation' here: http://msdn.microsoft.com/en-us/library/ms175933(v=sql.90).aspx - similar issue is discussed there.