SQLServer2005
Är det någon skillnad på:
o.Date BETWEEN @startdate AND @enddate
och
o.Date >= @startdate AND o.Date < dateadd(day,1,@enddate)
1 svar · 460 visningar · startad av Dino
SQLServer2005
Är det någon skillnad på:
o.Date BETWEEN @startdate AND @enddate
och
o.Date >= @startdate AND o.Date < dateadd(day,1,@enddate)
Fick svar.
The difference is if you have time portion stored in table by using BETWEEN
caluse you might ge a wrong result as SQL Server 'removes' time portion.
On the other hand with your second approac you WON'T get a wrong dataAlso, but you should be testing it, with the second option you may get
betterw performance as SQL Server most likely use and index on the column.I
do not say that it does not with the first one, just test it.