When I execute the following query in SQL Server 2005 it uses an index seek, as verified by viewing the execution plan.
SELECT *
FROM Account
WHERE Number = '123456789'
But when I run the same query, but use a parameter, it uses an index scan.
DECLARE @AccountNumber NVarChar(25)
SET @AccountNumber = '123456789'
SELECT *
FROM Account
WHERE Number = @AccountNumber
Since this table has over 10 million rows, the second query takes over 30 seconds while the first query takes only a few milliseconds. Do I really have to go and change all of my queries to not use parameters?