Select “where clause” evaluation order

前端 未结 7 1587
梦毁少年i
梦毁少年i 2020-12-06 09:40

In Sql Server 2005 when I have multiple parameters do I have the guarantee that the evaluation order will always be from left to right?

Using an exa

7条回答
  •  清歌不尽
    2020-12-06 09:59

    Short-Circuit is done when the condition we are referencing only includes literals or constants. So for example lets say we have a table TableA which has column num with all positive numbers from 1 to 10 and then if i write this query.

    Select num from TableA WHERE TableA.num < 0 AND 1/0 = 10.

    It will result in error.

    Is compiler smart enough to determine that my second clause is consists of constants so it should evaluate that before evaluating clause which requires any scan from table or index?

提交回复
热议问题