what should order of year day month in clause of tsql?
select * table_name year(column_name)=year(getdate()) --1 , day(column_name)=day(getdate()) --2 , month(column_name)=month(getdate()) --3
does order improve run time of query? how tsql execute statement?
if want improve performance, doing wrong. filters using won't use index (if there exists 1 on column_name
) because applying function them. right way compare column directly against getdate()
(on case). better way:
select * table_name column_name >= dateadd(day,datediff(day,0,getdate()),0) , column_name < dateadd(day,datediff(day,0,getdate()),1)
Comments
Post a Comment