how to update a null value field in sql server

eg
a table contains 3 fields id,name,salary
and 3 records
salary of 1 record is null
i want update the nullfield

111 arun 300
112 ddd 200
113 ttt null
i want to update table with add 100 to every record include null
after updation
the recrds should be
111 arun 400
112 ddd 300
113 ttt 100

Answer Posted / ganapathi

solution 1:
update table_name set
salary = isnull(salary,0) + 100

solution 2:
update table_name set
salary = case when
salary is null then 100
else salary + 100
end

Is This Answer Correct ?    49 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is merge?

565


what is a join and explain different types of joins? : Sql server database administration

534


What is the purpose of the tempdb database?

571


What is the difference between mysql and sql server?

467


How to update multiple rows with one update statement in ms sql server?

632






Explain a checkpoint?

532


What is a mutating table error and how can you get around it?

534


what is the difference between writing data to mirrored drives versus raid5 drives. : Sql server administration

534


What is report snapshot?

99


How real and float literal values are rounded?

583


How to send email from database?

577


How do you run a trace?

515


What is exporting utility?

537


What is the difference between the application object and session object?

597


John exports information periodically from a microsoft sql server database to an oracle database what is the best way to do this?

525