RE: Optimizing date searches

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



MS Sql Server LazyDBA home page