Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 evaluating OR condition

Author  Topic 

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-10-18 : 10:05:51
i was thinking (for a change )
does sql server evaluate OR in the same matter as C++
or is it different?

what i mean is:
c++:
(cond1 or cond2)
if cond1 is true cond2 doesn't even get evaluated

does sql server does the same thing or does it plan it's own order of evaluating where conditions?


Go with the flow & have fun! Else fight the flow

nr
SQLTeam MVY

12543 Posts

Posted - 2004-10-18 : 10:41:58
select 1 where 1=1 or convert(int,'1') = convert(int,'a')

The problem is that it is up to the optimiser how it creates the query plan and it can decide to change it at any time so it could decide to evaluate the second condition first.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-10-18 : 10:58:53
interesting.... thanx nigel

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -