RE: Optimizing date searches

RE: Optimizing date searches

 

  

Hmm... Ok, but in a case where the underlying column type is a datetime
but I'm really just looking for all records for a particular date (or
range) I'd still need to use the DateAdd trick wouldn't I?

-----Original Message-----
From: Jay Butler
[mailto:mssqldba-ezmlmshield-x73815591.[Email address protected]
Sent: Thursday, March 30, 2006 4:24 PM
To: LazyDBA Discussion
Subject: RE: Optimizing date searches

Internally, SQL Server probably processes those two constructs
identically (with the exception of excluding the begin point in your
">=").

But, neither of those will use an index on your table column if one
exists. You need to state the condition such that you reference the
column rather than some operation (like DateAdd) on the column.


-----Original Message-----
From: Ken Ross [mailto:mssqldba-ezmlmshield-x99131614.[Email address
protected]
Sent: Thu 30-Mar-06 15:10
To: LazyDBA Discussion
Subject: Optimizing date searches

O guru's of GUID, O sultans of SQL, O great wizards of WHERE...

When doing a search filtering by dates, is there any
advantage/disadvantage to doing:

... WHERE @mySearchDate >= Table.Date_Field AND @mySearcDAte <
DateAdd(dd, 1, Table.Date_Field)

VS.

... WHERE @mySearchDate BETWEEN Table.Date_Field AND DateAdd(dd, 1,
Table.Date_Field)


Thanks!!


Ken



---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY Website :
http://www.LazyDBA.com To unsubscribe:
http://www.lazydba.com/unsubscribe.html




---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY Website :
http://www.LazyDBA.com To unsubscribe:
http://www.lazydba.com/unsubscribe.html


MS Sql Server LazyDBA home page