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 / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what stored procedure can you use to display the current processes? : Sql server administration

528


What are group functions in query statements in ms sql server?

549


How to stop log file growing too big?

571


What is data modeling and Reterminal integrity?

1488


What method is used by the Command classes to execute SQL statements that return single values?

597






How do I find information about the install locations for the various instances running on a computer?

550


How to sort query output in descending order in ms sql server?

542


What is xdr?

558


Can you change the data type of a column in a table after the table has been created? If so, which command would you use?

633


Why is replication required on the sql server?

573


In which format does an image save in SQL Server database ?

584


What is update locks?

509


What does normalization do to data?

538


What is a non clustered primary key?

508


How do you rebuild an identity column?

542