Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Opportunistic or?
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01083884
Message ID:
01083891
Vues:
9
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--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform