Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
Solved

# replace NULL with 0.00

Posted on 2004-10-01
Medium Priority
296 Views
i want to replace a table in which columns has <NULL> value with 0.00. How to do that

I tried this way
update OrderSep
Set wless_doll= 0.00
Where wless_doll= NULL

but this doesn't works I dnt know why?.. Can anyone help
0
Question by:ajaypappan

LVL 15

Assisted Solution

mcmonap earned 100 total points
ID: 12200724
Hi ajaypappan,

update OrderSep
Set wless_doll = 0.00
Where wless_doll IS NULL
0

LVL 3

Author Comment

ID: 12200806
How can i do it for multiple fields?
suppose i have these columns
wless_doll
wless_comm
wless_charge

How to do all at a time?
0

LVL 18

Expert Comment

ID: 12200818
yep as mc says you need to use IS NULL as opposed to = NULL . As NULL  by definition is the absence of a value, by default you can not compare them with =  because = is an equallity check and it is not strictly correct that NULL = NULL (ie an unknown = an unknown)
0

LVL 5

Expert Comment

ID: 12200870
ShogunWade, =NULL and IS NULL will both work. It used to be IS NULL was quicker but AFAIK this is no longer the case ..
0

LVL 26

Accepted Solution

Hilaire earned 100 total points
ID: 12200877
>>How can i do it for multiple fields?<<
try

update OrderSep
Set wless_doll = isnull(wless_doll , 0.00),
wless_comm = isnull(wless_comm , 0.00),
wless_charge = isnull(wless_charge , 0.00)
Where wless_doll IS NULL or wless_comm is null or wless_charge is null
0

LVL 18

Expert Comment

ID: 12200919
UPDATE ordersep
set wless_doll = ISNULL(wless_doll,0),
wless_doll = ISNULL(wless_doll,0),

...etc...
0

LVL 18

Expert Comment

ID: 12200981
hkamal ", =NULL and IS NULL will both work."     as I stated     "by default you can not compare them with = "  this istatement s correct.

It is not ANSI standard to compare NULLS using =    SQL Server gives you the ability to do this by unsing SET ANSI_NULLS OFF    but the ANSI standard is default here!

0

LVL 5

Expert Comment

ID: 12201008
Having ISNULL in the SET clause does NOT prevent it updating ALL columns in the SET if ANY of the criteria in the WHERE is satisfied
However, unless you have three (or as many column as you have) successive UPDATEs, you just have to live with it ;-)
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
###### Suggested Courses
Course of the Month11 days, 2 hours left to enroll