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

While you are inserting values into a table with the insert into .. Values option, does the order of the columns in the insert statement have to be the same as the order of the columns in the table?

623


How many joins in sql server?

518


Write a query for primary key constraint with identity key word?

577


What is service broker? : sql server database administration

580


Does order by actually change the order of the data in the tables or does it just change the output?

680






What is difference between inner join and full join?

554


In case you have filters in your report, when filters will be applied in cached report instance?

81


Can you leave a union at any time?

541


What is built-in/administrator?

576


What is relationship? What number of sorts of relationship are there?

639


What is the index requirement in SQL Azure?

72


What are the events recorded in a transaction log?

508


What is the difference between clustered index and primary key?

507


what is the system function to get the current user's user id? : Sql server database administration

557


When would you use the stored procedures or functions?

576