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.
| Author |
Topic |
|
laailalalaa
Yak Posting Veteran
57 Posts |
Posted - 2010-05-09 : 14:34:07
|
| i know the following is true in many programming languages, please confirm whether this also applies to t-sql:IF condA OR condB OR condCTHEN ...condC will be evaluated only if both condA and condB fail, right?thanks |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-05-09 : 15:19:25
|
It depends on what the boolean checks are.SQL Server treats all operators in terms of costs. In you example, SQL Server may very well try condC first! N 56°04'39.26"E 12°55'05.63" |
 |
|
|
laailalalaa
Yak Posting Veteran
57 Posts |
Posted - 2010-05-09 : 15:24:05
|
| got it, thanks Peso |
 |
|
|
ms65g
Constraint Violating Yak Guru
497 Posts |
Posted - 2010-05-09 : 15:27:43
|
It is not equivalence?IF condA --THENELSE IF CondB --THEN ELSE IF CondC --THEN |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-05-10 : 01:27:10
|
No.If condA is considered more costly to evaluate, condC may be evaluated first. Or condB. And condA last. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
ms65g
Constraint Violating Yak Guru
497 Posts |
Posted - 2010-05-10 : 06:14:19
|
| Thanks Peso,Could you please give me a link for reference for this subject? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
ms65g
Constraint Violating Yak Guru
497 Posts |
Posted - 2010-05-10 : 14:38:40
|
| Thanks, but link do not word for me. Not implortant |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-05-14 : 00:40:20
|
quote: Hi,You already posted about cost based.I want to know WHEN clauses in CASE are evaluated in order or not?
In a CASE statemnt, the clauses are always evaluated in the order they are written, until one is found true. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
|
|
|