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
 General SQL Server Forums
 New to SQL Server Programming
 Computed Column Help

Author  Topic 

benking9987
Posting Yak Master

124 Posts

Posted - 2009-12-03 : 11:24:41
I have a computed column (Total) that adds up 8 previous columns. Some of the values in the previous 8 columns are null, so the compute formula for those records does not work obviously.

My front end is MS Access and I know there is a function when querying that allows the value in the null field to be treated as a ZERO for purposes of giving a value for the sum function. Is there anything similar to this functionality when using a SQL computed column?

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-12-03 : 11:51:29
Try with isnull

Example

udpate <tablename>
set Total= isnull(0,col1)+isnull(0,col2)/isnull(0,col3)...

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

benking9987
Posting Yak Master

124 Posts

Posted - 2009-12-03 : 12:38:42
Awesome thanks.
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-12-03 : 12:47:51
quote:
Originally posted by benking9987

Awesome thanks.



Welcome

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page
   

- Advertisement -