By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,026 Members | 2,085 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,026 IT Pros & Developers. It's quick & easy.

setting a null value to zero in a stored procedure

P: 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
Share this Question
Share on Google+
3 Replies


azimmer
Expert 100+
P: 200
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
Expert 100+
P: 200
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
Expert 2.5K+
P: 2,878
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

Post your reply

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