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
 How to convert null to currency or numeric

Author  Topic 

btamulis
Yak Posting Veteran

64 Posts

Posted - 2006-05-12 : 13:27:07
Greetings -

I have a problem that I am unable to fix. I am migrating data from one ERP system to another ERP system.

I created a table in SQL via DTS by converting an excel file into an SQL Table.

The table has a column 'currentcost'. Most items in the table have a value in this column. However, some items have <null> in this column. I am updating another SQL table with currentcost that is in this column. However, my table being updated requires a value in its corresponding currentcost table. Therefore, my update statement terminates due to the source table having <null> values.

I tried an update statement to convert <null> into a '0'

It was 'update Source_New_ItemMaster set currentcost = '0' where currentcost = <null>

This obviously didn't work. How can a change a <null> value in an SQL table to '0' (zero)?

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-05-12 : 14:09:42
[code]
update Source_New_ItemMaster
set
currentcost = 0
where
currentcost is null

[/code]

CODO ERGO SUM
Go to Top of Page

btamulis
Yak Posting Veteran

64 Posts

Posted - 2006-05-13 : 12:03:51
Thanks -
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-15 : 03:02:12
If you want to avoid having NULLs in future, alter it to have a default value 0

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -