Query runs slow with date expression, but fast with string literal
I am running a query with below condition in SQL Server 2008.
Where FK.DT = CAST(DATEADD(m, DATEDIFF(m, 0, getdate()), 0) as DATE)
Query takes forever to run with above condition, but if just say
Where FK.DT = '2013-05-01'
it runs great in 2 mins. FK.DT key contains values of only starting data
of the month.
Any help, I am just clueless why this is happening.
 
No comments:
Post a Comment