I am getting a big performance hit when I say
DECLARE @FinalDay DATETIME
SET @FinalDay= DATEADD(dd,-1*200,GETDATE())
WHEREOrderDate > @FinalDay (takes 2 secs)
but this performs much faster without using the variable.
WHERE OrderDate > DATEADD(dd,-1*200,GETDATE()) (takes less than a second)
is there anyway I can utilize the first query with better performance since @FinalDate is a varable that will need to change.
Thank You