What if your dates are in variables, like:
Declare @EndDate as datetime
Declare @StartDate as datetime
Set @StartDate = '20111101'
Set @EndDate = '20111130'
create_date >= @StartDate and create_date < @EndDate
SQL Server doesn't want to use the index when that's done. If you have a stored procedure where the dates are passed in, how do you get the index on the datetime column used?
commented on Dec 7 2011 6:52PM