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
What are pessimistic lock and optimistic lock?
Can you please explain the difference between primary keys and foreign keys?
How to filter out duplications in the returning rows in ms sql server?
Can you explain full-text query in sql server?
How is foreign key related to primary key?
How to assign new column names in a view?
Describe in brief databases and sql server databases architecture.
How do I completely remove sql server instance?
How to use “drop” keyword in sql server and give an example?
What does the not null constraint do?
What is @@rowcount in sql?
How do you handle datasets larger than 50 gb?
What is dbcc?
What are “unrepeatable reads”?
Explain what is the main purpose of having conversation group?