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 is reportserver and reportservertempdb ?

107


Mention a few common trace flags used with sql server?

544


How to maintain a fill factor in existing indexes?

533


What are wait types?

588


What is 1nf 2nf?

554






How many types of subqueries are there in sql server?

469


Do you know what are the ways available in sql server to execute sql statements?

545


How many ways to create table-valued functions?

586


What is the server name for sql management studio?

477


What is auditing in sql server?

505


How do we know if any query is retrieving a large amount of data or very little data?

553


What is the order in which the sql query is executed?

525


What is a fan-out query in SQL Azure?

99


Explain about merge replications?

595


What are the dmvs?

572