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 query

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 =@Bond

and

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.. it

Complicated things can be done by simple thinking
Go to Top of Page

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 :)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-16 : 02:32:32
A.Bond = IsNull(@Bond, A.Bond) is equivalent to

If @Bond is null then
A.Bond=A.Bond
else
A.Bond=@Bond


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

mmarovic
Aged Yak Warrior

518 Posts

Posted - 2005-08-16 : 04:32:35
quote:
A.Bond = IsNull(@Bond, A.Bond) is equivalent to

If @Bond is null then
A.Bond=A.Bond
else
A.Bond=@Bond
True. Condition a.Bond = a.bond will filter out rows where a.bond is null.
Go to Top of Page
   

- Advertisement -