if there are a large number of records in the table, then you do not want to do a CONVERT on the column to compare with the constant as this is inefficient and will always result in a table scan. from an optimization/performance standpoint, you want to get your constants into the proper format and directly compare to the column (which presumably is indexed).
for instance, instead of:
Select *
from table1
where CONVERT(Char,date1,101) = '1/2/2004'
use :
Select *
from table1
where date1 >= '1/2/3004'
and date1 < '1/3/2004'
or, if you're a purist:
Select *
from table1
where date1 >= CONVERT(datetime,'1/2/3004')
and date1 < CONVERT(datetime,'1/3/2004')
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.