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 / ganesh.k

UPDATE Table_Name SET Salary = COALESCE(Salary,0) + 100

(Or)

UPDATE Table_Name SET Salary = ISNULL(Salary,0) + 100

Is This Answer Correct ?    15 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the differences between union, intersect, and minus operators?

578


What can be used instead of trigger?

631


How many types of dimensions are there and what are they? : sql server analysis services, ssas

567


What is tablix?

115


Can we update data in a view?

604






Mention the command used to rename the database.

536


What is the use of “join” in sql server?

574


Mention the 3 ways to get a count of the number of records in a table.

555


How to drop an existing user defined function in ms sql server?

570


Explain what is lock escalation and what is its purpose?

513


How to query multiple tables jointly?

560


You are creating an application where users are asked their gender in the gender combo box you have three options: ‘male’ , ‘female’ and ‘i choose not to disclose’ these options are stored in the table as 1, 0 or null which datatype should you use?

549


List some of the rules that apply to creating and using a ‘view’

500


what is package and it uses and how can u call a package

1563


How many non clustered indexes there can be on table ?

511