Scenario:
log table with a considerable amount of records (2 Million) with a timestamp field.
no indexes except for the ID as a primary key, and index (or any other persistent object) creation is out of the question
I want to select all records from yesterday.
I know there are a few ways of doing it, I just would like opinion on the “best” way, and by best I mean fastest.
the trick here is the “time” of the timestamp, because if now is 11AM and I do something like:
where modifiedDate between dateadd(dd,-1,getdate()) and getdate()
Ill get records only from yesterday at 11 and will get data from today
Its sql 2005 so there is no “Date” datatype
SQL Fiddle with Demo