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)
 SQL Processing Order

Author  Topic 

coderdude
Starting Member

24 Posts

Posted - 2005-07-09 : 03:57:02
Does SQL Server process WHERE statements top-to-bottom or bottom-to-top? Or does it matter? Also, I wonder the same question about the JOIN statements. I remember back in my Oracle days that Oracle did process them in a certain order. Can anyone shed some light on this from a SQL Server point of view?

Thanks!

SamC
White Water Yakist

3467 Posts

Posted - 2005-07-09 : 08:53:38
I don't know about Top to Bottom, but

WHERE @Myparm IS NULL OR @MyParm = MyColumn

is processed left to right. I always code parameter checks on the left to benefit from the code execution sequence.

If several are stacked, I don't know if the first condition is executed before the last

WHERE cond a
AND cond b
AND cond c
Go to Top of Page
   

- Advertisement -