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)
 Using IN vs. OR

Author  Topic 

texasweb
Starting Member

11 Posts

Posted - 2008-03-19 : 13:02:41
has anyone found a difference between IN and Or. The only difference that I see is the time to type the code for the OR statement.

Our DBA is adamant about not using the IN, he says that takes up too many resources. I have run this thru our test and found that IN has better results, does he know something that I am not seeing?

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-03-19 : 13:24:25
Yes, your DBA is right. But you need to have index for the columns in OR clause , Otherwise execution plan will result in table scan.

If you have lots of OR in Query, better use union all.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-03-19 : 13:33:13
There is no difference between IN and OR, they are the exact same thing, just with different syntax.

If you find a performance difference between using IN and OR, post your situation and we can take a look. Most likely this means your two expressions are not logically equivalent. (i.e., are you missing parenthesis?)

Note that this does not cover using IN instead of doing a JOIN; that is a different topic altogether. Maybe that's what your DBA was referring to?

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -