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
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / 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 |
Answer / mohan
create table #temp (eid int, names varchar(10),sal int)
insert into #temp values (111, 'arun', 300)
insert into #temp values(112, 'ddd', 200)
insert into #temp values(113,'ttt',null)
select * from #temp
update #temp
set sal = isnull(sal,0)+ 100
select * from #temp
| Is This Answer Correct ? | 6 Yes | 2 No |
Answer / justus
update tablename set salary=100 where salary is null
| Is This Answer Correct ? | 6 Yes | 10 No |
Answer / dinesh sharma
It Simple
Just Write Down The Query
update table_Name set salary=100 where salary is null
| Is This Answer Correct ? | 12 Yes | 28 No |
What are the default system databases in sql server 2000?
What is database replication? What are the different types of replication you can set up in sql server?
Can you name a few encryption mechanisms in sql server?
What is usually the first word in a sql query?
What is difference between views and tables?
How will you hide an attribute? : sql server analysis services, ssas
How to make remote connection in database?
plss anybody specify tha constrian management system in dbms
What are the differences between local and global temporary tables?
Explain primary key, foreign key and unique key?
What do you mean by an execution plan? Why is it used?
There is a trigger defined for INSERT operations on a table, in an OLTP system. The trigger is written to instantiate a COM object and pass the newly insterted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)