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)
 How to convert NULL to money value

Author  Topic 

zurbum
Yak Posting Veteran

55 Posts

Posted - 2004-11-12 : 13:49:27
I want to convert NULL to 0 money, is this possible?

Imagine to have 2 tables, DEPOSIT and WITHDRAW
If I want to know, how much money a person has on account I would do

SELECT (SELECT SUM(MON) FROM DEPOSIT WHERE ID=1) - (SELECT SUM(MON) FROM WITHDRAW WHERE ID=1)

But if there isn't any record in WITHDRAW table, the result is NULL.
How to avoid this in the easiest way?

dsdeming

479 Posts

Posted - 2004-11-12 : 13:55:01
See ISNULL or COALESCE in BOL.

Dennis
Go to Top of Page

zurbum
Yak Posting Veteran

55 Posts

Posted - 2004-11-12 : 14:11:52
Great, ISNULL has done its work.
Thank you Dennis.
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-11-12 : 17:08:55
COALESCE is SQL Standard, ISNULL is TSQL extension.

rockmoose
Go to Top of Page
   

- Advertisement -