SQL Short Circuit Mechanism and OR

Short circuit works in sql much like any other logical system. Given a sequence of expressions, connected by an OR operatorthe first expressions to evaluate as true, from left to right, exits the group as true.

As an example:

@var1=5,@var2=20,@var3='Live'

Where (@var1>2 or @var2<=15 or s.column=@var3)

The above statement will return true since @var1 is true regardless of the values of @var2 and @var3. This is important to realize since sql will not adjust the order of your expressions if they are part of an OR operation. Above you would prefer to make sure @var1 or @var2 fails before running the compare with the table, which is why I put them first.