SQLTeam.com | Weblogs | Forums

NULL Values


#1

Hello - I have a table resulting from another query but some of the values are NULL. This is correct too.....Here is how the data appears now:

Network Name Jan Feb Mar Apr
1 Bob NULL 2 NULL 4
2 Fred 5 NULL 3 NULL

I would like to replace the NULL values with zeros, so it looks like this:

Network Name Jan Feb Mar Apr
1 Bob 0 2 0 4
2 Fred 5 0 3 0

Can anyone please help me to do that?

Thank you!

John


#2

isnull(yourfield,0)


#3
UPDATE U
SET Jan = IsNull(Jan, 0)
    , Feb = IsNull(Feb, 0)
...
FROM YourTableName AS U

But why do you want to change NULL to ZERO? Is the value known to be Zero? or is it actually "unknown" (and you are using NULL to signify "unknown")?