Groups | Blog | Home
all groups > sql server mseq > october 2005 >

sql server mseq : NULL encountered in math


Joseph
10/31/2005 3:50:03 PM
I need to subtract two values in a table. One of these values contains a
NULL entry. Each time I use the (Pledge - Credit) as 'Difference' I get the
value of NULL.

How do I get T-SQL to replace the NULL with zero?

I encountered this a long time ago while concatenating data. I was able to
use the command SET CONCAT_NULL_YIELDS_NULL OFF for strings. But I can't
find anything for numbers.

David Portas
11/1/2005 9:08:14 PM
[quoted text, click to view]

You can use COALESCE or ISNULL. Example:

COALESCE(pledge,0) - COALESCE(credit,0) AS difference

--
David Portas
SQL Server MVP
--

AddThis Social Bookmark Button