Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I joined two tables using "left join". There are some null fields in my result table.I need to assign 0(zero) to those fields.Please help me with in single queary line.(Consider this table is a result of an query.So it hasn't a name)
Posted
Updated 27-Dec-12 21:30pm
v2

e.g.
SQL
select Product_id,Product_name,IsNull(Product_Price,0) from tbl

Happy Coding!
:)
 
Share this answer
 
If you are talking of retrieving values then:
SQL
SELECT 
  someFields,
  IsNULL(fieldThatCanbeNullAndNeedsReplacement, 0)
FROM
  myTable

Refer: MSDN: ISNULL (Transact-SQL)[^]
 
Share this answer
 
v2
Use case statement in query like .....

select col1, col2,
case
when yourColumn3 IS NULL then 0
else yourColumn3
end as YourColumnName
from your_Table

it may solve your problem
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900