I have the following table in SQL Server 2008:
Session
(
sessionid varchar(10)
startdate dateteime
enddate dateteime
--rest of the fields go here
)
I have the following two nonclustered indexes created:
Inddex1: SessionID,startdate,enddate
Inddex2: startdate,enddate
I have the following query
select *
from session
where startdate>=@date1 and enddate <=@date2
on executing this query, both these idexes are not used. The query plan only shows the table scan.
Now I tried removing the index1 and executed the same SP Still index2 is not being used.
Any clues on how to make the SP to use index2? (No forced index use please.)