I have a query that reacts too long when the search parameter is a date type varchar data type. However, if I convert varchar to a datetime variable, the query runs fine. For example:
It takes too much time.
select count(id) from names where updateddate > '1/5/2010'
This is normal.
declare @dateparam datetime set @dateparam = convert(datetime, '1/5/2010',102) select count(id) from names where updateddate > @dateparam
Which reason is working fine and the other not?
source share