Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

replace NULL with 0.00

Posted on 2004-10-01
8
Medium Priority
?
284 Views
Last Modified: 2012-05-05
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
Comment
Question by:ajaypappan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 15

Assisted Solution

by:mcmonap
mcmonap earned 100 total points
ID: 12200724
Hi ajaypappan,

try this instead:

update OrderSep
Set wless_doll = 0.00
Where wless_doll IS NULL
0
 
LVL 3

Author Comment

by:ajaypappan
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

by:ShogunWade
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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 5

Expert Comment

by:hkamal
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

by:
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

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

...etc...
0
 
LVL 18

Expert Comment

by:ShogunWade
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

by:hkamal
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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question