SQL Server Performance

between operator performance

Discussion in 'SQL Server 2005 General DBA Questions' started by ismailadar, Mar 18, 2010.

  1. ismailadar New Member

    hi All,
    I wonder about is there any difference between using " where total>=30 and total<50 " and " where total between 30 and 50"?
    Is there any performance difference between two usage?Which one do you prefer?

    tahnx in advance.
  2. Adriaan New Member

    They're not the same!
    WHERE a BETWEEN x AND y -- includes the y value.
    WHERE a >= x AND a < y -- does not include the y value
    You can use the second type of criteria range when searching on a DATETIME column where you want to return a date range, and dates have a time part (other than 0:00 AM). If you would use CONVERT on the searched column to eliminate the time part, to get any time on the end date, then performance may suffer. If you do the calculation on the end date, performance is less likely to suffer:
    WHERE a >= x AND a < DATEADD(DAY, 1, y)
    Other than that, I'm pretty sure SQL Server will apply the same execution plan to both queries.

Share This Page