|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 4:22 PM
Points: 10,990,
Visits: 10,542
|
|
GilaMonster (11/17/2011)
Ola L Martins-329921 (11/17/2011) The "AND" operator will check against the date-columns seperately - not simultaneously which in the case with "BETWEEN". Using GREATER THAN and LESS THAN in the above question would actually return all the records.BETWEEN is completely equivalent to a combination of <= and >= SomeColumn BETWEEN @Var1 and @Var2 is exactly the same as SomeColumn >= @Var1 and SomeColumn <= @Var2. In fact, the SQL parser converts the BETWEEN into the <= and >= form during parsing (pre-execution) Interesting side-fact: BETWEEN is not valid in a filtered index definition; you have to expand the condition into >= and <= tests.
Paul White SQL Server MVP SQLblog.com @SQL_Kiwi
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Thursday, September 27, 2012 4:24 AM
Points: 253,
Visits: 78
|
|
| Thanks to all who posted comments. I myself got to learn more by reading all the comments.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 7:51 AM
Points: 1,085,
Visits: 1,166
|
|
|
|
|