Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Opportunistic or?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01083884
Message ID:
01083891
Views:
10
This message has been marked as the solution to the initial question of the thread.
>Is the OR statement opportunistic in SQL Server 2000?
>
>IOW, if the first condition is met, does it check the second?

Hi Justin,

This feature is called short circuit and T-SQL supports it.
IF (1 > 0) OR (1/0 > 0)
  PRINT 'Short circuit'

IF (1/0 > 0) OR (1 > 0) 
  PRINT 'Short circuit'

DECLARE @a int, @b int
SELECT @a=1, @b=0

IF (@a > @b) OR (@a/@b > @b) 
  PRINT 'Short circuit'

IF (@a/@b > @b) OR (@a > @b) 
  PRINT 'Error'
Keep in mind that Query Optimizer can rearange the order of expressions.
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform