473,386 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

setting a null value to zero in a stored procedure

1
Am trying to update a table with values from another table but not all cloums are supposed to be updated so am ending up with null values how do i change these null values to zero so that the empty cloum will have zero
Sep 3 '07 #1
3 2854
azimmer
200 Expert 100+
Am trying to update a table with values from another table but not all cloums are supposed to be updated so am ending up with null values how do i change these null values to zero so that the empty cloum will have zero
use 'case':
Expand|Select|Wrap|Line Numbers
  1. SELECT (CASE WHEN myColumn IS NULL THEN 0 ELSE mycolumn END) as myNewColumn
  2. ...
  3.  
Sep 3 '07 #2
azimmer
200 Expert 100+
use 'case':
Expand|Select|Wrap|Line Numbers
  1. SELECT (CASE WHEN myColumn IS NULL THEN 0 ELSE mycolumn END) as myNewColumn
  2. ...
  3.  
or better yet (standard SQL):
Expand|Select|Wrap|Line Numbers
  1. SELECT COALESCE(myColumn,0) as myNewColumn
  2. ...
  3.  
Sep 3 '07 #3
ck9663
2,878 Expert 2GB
or better yet (standard SQL):
Expand|Select|Wrap|Line Numbers
  1. SELECT COALESCE(myColumn,0) as myNewColumn
  2. ...
  3.  

select isnull(mycolumn,0)...
Sep 3 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: piero | last post by:
Hi, I have write a stored procedure which makes update in a numeric (int) field. Depending on data in other table, in some case the result of query get a Null value instead a zero value... ...
3
by: Gaz | last post by:
I have a table which has 10 columns which make up the secondary key. 1 or more of these columns can be set but the remaining columns in the secondary key will be null. For example : id k1 k2...
3
by: CSDunn | last post by:
Hello, I currently have an Access 2003 ADP Report/Subreport set up in which I have 12 subreports in a single main report that are located in a group header called 'PermnumHeader' (Permnum would be...
102
by: junky_fellow | last post by:
Can 0x0 be a valid virtual address in the address space of an application ? If it is valid, then the location pointed by a NULL pointer is also valid and application should not receive "SIGSEGV"...
5
by: Sandy | last post by:
Hello - I need a good example of how to take a return value from a stored procedure and use it in vb code. I have an app that searches a database by city and state. If a user makes a typo, the...
1
by: David Shorthouse | last post by:
Hey folks, I am attempting to pass null as the input value from a series of textboxes if the user does not input a value prior to submit. To try and do this, I am using a vbscript function on...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
3
ADezii
by: ADezii | last post by:
Null as it relates to database development is one of life's little mysteries and a topic of total confusion for novices who venture out into the database world. A Null Value is not zero (0), a zero...
2
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.