Order of operations and Short circuit
-
Hi all, I have a couple of questions that I hoping someone will know off the top of their head regarding SQL Server 2000. 1) Is there a short circuit mechanism in the if/case program controls? I would think so but logic doesn't rule the day unfortunatley. 2) In an update statement, is it necessarily true that a field will be updated in the order it was presented in the update statement? Best Regards, Keith
-
Hi all, I have a couple of questions that I hoping someone will know off the top of their head regarding SQL Server 2000. 1) Is there a short circuit mechanism in the if/case program controls? I would think so but logic doesn't rule the day unfortunatley. 2) In an update statement, is it necessarily true that a field will be updated in the order it was presented in the update statement? Best Regards, Keith
If you are talking about short circuiting in boolean conditions, then the answer is no. Fields will not necessarily be updated in the order they are presented. Some fields require more work in an update, and (in a multi-processor environment) the operations to do this can happen alongside other parts of the update.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before. -
If you are talking about short circuiting in boolean conditions, then the answer is no. Fields will not necessarily be updated in the order they are presented. Some fields require more work in an update, and (in a multi-processor environment) the operations to do this can happen alongside other parts of the update.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.wow, no short circuting of booleans, eh? So (X > 0 AND Y < 3), if x is -1 it will still evaluate y < 3? That's crazy! On doing the updates, I kind of figured that. I'm not too familar on what goes on behind the scenes like if it locks the whole record or locks at the field level. I can work with both these issues and will be good to know for the future. Do you know if this is any different in SQL Server 2005? I know my company will be upgrading here sometime in the future ( I have seen the install discs with my own eyes). I just hope that whatever I have done will be easy to port over. :( Best Regards, Keith
-
If you are talking about short circuiting in boolean conditions, then the answer is no. Fields will not necessarily be updated in the order they are presented. Some fields require more work in an update, and (in a multi-processor environment) the operations to do this can happen alongside other parts of the update.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.Hello Friend, Happy Valentines Day. Before concluding anything about TSQL short circuiting, I would like to request you to visit http://www.sqlservercentral.com/faq/viewfaqanswer.asp?categoryid=3&faqid=360[^].
Mehedi Hasan
-
Hello Friend, Happy Valentines Day. Before concluding anything about TSQL short circuiting, I would like to request you to visit http://www.sqlservercentral.com/faq/viewfaqanswer.asp?categoryid=3&faqid=360[^].
Mehedi Hasan
Very interesting. Well, that throws the conventional wisdom out of the window.:-D
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.