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 autocommit mode in sql server?

708


Explain what is use of dbcc commands?

710


How do I schedule a sql server profiler trace?

701


Explain transaction isolation levels in sql server?

742


What is the difference between osql and query analyzer?

716






Write an sql query to find first weekday of the month?

664


What is a covering index?

719


What is transact-sql ddl trigger?

810


Can foreign key be deleted?

679


What do you do in data exploration

720


What is an entity-relationship diagram (erd)?

805


What is sql azure database?

198


How do you Implement SSIS Packages in your Project?

1671


How do I view views in sql server?

694


In which tcp/ip port does sql server run? Can it be changed?

720