ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
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
 Question Submitted By :: K L Baiju
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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
# 1
It Simple
Just Write Down The Query
 update table_Name set salary=100 where salary is null
 
Is This Answer Correct ?    6 Yes 11 No
Dinesh Sharma
 
  Re: 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
# 2
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 ?    24 Yes 1 No
Ganapathi
 
 
 
  Re: 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
# 3
UPDATE Table_Name SET Salary = COALESCE(Salary,0) + 100

(Or) 

UPDATE Table_Name SET Salary = ISNULL(Salary,0) + 100
 
Is This Answer Correct ?    6 Yes 0 No
Ganesh.k
 
  Re: 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
# 4
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 ?    2 Yes 0 No
Mohan
 
  Re: 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
# 5
update #temp
set sal = COALESCE(sal+100,100)
 
Is This Answer Correct ?    1 Yes 0 No
Mohan
 
  Re: 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
# 6
update tablename set salary=100 where salary is null
 
Is This Answer Correct ?    2 Yes 1 No
Justus
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
What is indexed views? plz explain with example?  1
What is a stored procedure?  3
What is the difference between a Application Server and a Database Oracle2
If there exist a index on the table, and we then make a view on that table (include the indexed column from base table) than why do we require indexing on view?Doesnt it create an overhead?  1
How to link up the text file to a Database table? Allianz1
Questions regarding Raiseerror?  1
About Indexed Views? with example? plz reply...  2
Explain fundamentals of Data ware housing & OLAP?  1
what is difference between primary key and Unique  8
What is the difference between Userdefined function and stored procedure? Explain and give the example also  4
can we call functions from stored procedure in SQL Server 2005 ? How?  2
could you please reply for these question: 1.About Use Apply? 2.Avoid cursors - When we have a situation that we can not avoid the use of cursor than what is the alternate solution? is there anything we can use instead of cursor to perform the desired task? which optiomize the peroformance too. 3.What is computed columns? Thanks in advance. Regards, Rupesh  3
Explain basic SQL queries with SELECT from where Order By, Group By-Having? Wipro2
i have a table #temp1(id, Name groupname ) and record like this 1 R1 S 2 R3 S 3 R2 S 4 R4 D 5 R5 D 6 R6 K 7 R7 K 8 R8 L 9 R9 L 10 R10 L 11 R11 K and i want to display record based on user defind sorting order e.g. 1 R4 D 2 R5 D 3 R6 K 4 R7 K 5 R11 K 6 R1 S 7 R3 S 8 R2 S 9 R8 L 10 R9 L 11 R10 L  4
Rate yourself in .NET and SQL ? Cognizent1
What is Files and Filegroups in SQL Server & it's implementation. Zenith1
I have a huge amount of data which is displayed in a report. The data is viewed every day. Every day the data is displayed in 30 secs but suddenly today it is giving an timeout message today. Data has not been changed. The situation is same as yesterday. What might be the reason??? Please Answer. Satyam4
What is the use of CASCADE CONSTRAINTS?  2
what is Archive old data?  1
Difference Between varchar and nvarchar datatype? Satyam2
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com