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)
 Null Values

Author  Topic 

MrZen
Starting Member

2 Posts

Posted - 2005-02-24 : 17:54:31
Got a problem with a SQL server table. I need to go through all rows in the table and replace null values with 0. Any help with this appreciated. I want to keep all column names the same. Its only the null values that I would like to change.

HISTORY BEHIND THIS MESS...: I export the table into an excel spreadsheet. The macro on the spreadsheet can not handle null values and falls over.

Thanks

MichaelP
Jedi Yak

2489 Posts

Posted - 2005-02-24 : 18:04:00
[code]
--For numeric
UPDATE myTable Set myfield = 0 where myfield IS NULL

--For string
UPDATE myTable Set myfield = '0' where myfield IS NULL
[/code]

Michael



<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

Xerxes
Aged Yak Warrior

666 Posts

Posted - 2005-02-24 : 18:04:03
Try this topic for your answer....

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=46197


Semper fi,

XERXES, USMC(Ret.)
------------------------------------------------------
Once a Marine ALWAYS a Marine!
Go to Top of Page

Xerxes
Aged Yak Warrior

666 Posts

Posted - 2005-02-24 : 18:04:20
Try this topic for your answer....

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=46197


Semper fi,

XERXES, USMC(Ret.)
------------------------------------------------------
Once a Marine ALWAYS a Marine!
Go to Top of Page

MrZen
Starting Member

2 Posts

Posted - 2005-02-25 : 03:48:40
Can I get the above set command for a numeric example, to include multiple columns into one statement to keep the code tidy or is it a whole statement per column?

Thanks
Go to Top of Page
   

- Advertisement -