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)
 nullif and left join problem

Author  Topic 

adlo
Posting Yak Master

108 Posts

Posted - 2004-09-02 : 12:19:47
I got a NULLIF(SkillCount,0) as SkillCount in my select statement but it still gives me NULL as value.

It must display 0 for the Null values caused by the left outer join.

I can't understand why is won't work.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-09-02 : 12:21:42
because
NULLIF
Returns a null value if the two specified expressions are equivalent.

i think you need
ISNULL
Replaces NULL with the specified replacement value.



Go with the flow & have fun! Else fight the flow :)
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-09-02 : 12:22:12
isnull(skillcount, 0) ......
or coalesce(skillcount, 0)
should do it.



Duane.
Go to Top of Page

adlo
Posting Yak Master

108 Posts

Posted - 2004-09-02 : 12:24:35
Sorry, I mixed them up.
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-09-02 : 12:29:17
BTW
I can remember a thread from this site a couple of months ago where my freind Kristen had decided that he was going to enforce coalesce over isnull at his company as coalesce was ansi standard and isnull was not and another good reason was beacuase coalesce can use multiple values as input params - it just returns the first non null value (this can be very handy at times)



Duane.
Go to Top of Page
   

- Advertisement -