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
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?
How many joins in sql server?
Write a query for primary key constraint with identity key word?
What is service broker? : sql server database administration
Does order by actually change the order of the data in the tables or does it just change the output?
What is difference between inner join and full join?
In case you have filters in your report, when filters will be applied in cached report instance?
Can you leave a union at any time?
What is built-in/administrator?
What is relationship? What number of sorts of relationship are there?
What is the index requirement in SQL Azure?
What are the events recorded in a transaction log?
What is the difference between clustered index and primary key?
what is the system function to get the current user's user id? : Sql server database administration
When would you use the stored procedures or functions?