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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-08-15 : 07:43:53
|
| cognos writes "Can anyone tell whts the difference between these two statements. @Bond Is Null OR A.Bond =@Bondand A.Bond = IsNull(@Bond, A.Bond)I am getting different resultset with these statements.Any help is appreciated" |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2005-08-15 : 07:50:00
|
| The first codition means.. that you are checking for whether the value in the @Bond Variable is null or the columns Bond value is equal to @Bond.Where as in the second.. your replacing the value of @bond to A.Bond if the @bond is null ..i hope you understood.. itComplicated things can be done by simple thinking |
 |
|
|
mmarovic
Aged Yak Warrior
518 Posts |
Posted - 2005-08-15 : 11:14:45
|
| The second query will not evaluate to true when a.bond is null regardless of the value of @bond paramater. Null is not equal to anything even another null :) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-16 : 02:32:32
|
| A.Bond = IsNull(@Bond, A.Bond) is equivalent toIf @Bond is null thenA.Bond=A.BondelseA.Bond=@BondMadhivananFailing to plan is Planning to fail |
 |
|
|
mmarovic
Aged Yak Warrior
518 Posts |
Posted - 2005-08-16 : 04:32:35
|
quote: A.Bond = IsNull(@Bond, A.Bond) is equivalent toIf @Bond is null thenA.Bond=A.BondelseA.Bond=@Bond
True. Condition a.Bond = a.bond will filter out rows where a.bond is null. |
 |
|
|
|
|
|