Вы находитесь на странице: 1из 4

12/24/2016 SQL Server Interview Questions: What are the different ways to replace NULL values in SQL Server

0   More    Next Blog» Create Blog   Sign In

SQL Server Interview Questions
C#
Boo MV ASP. C SQL W Written HR Subsc SQL Buy
Program 0
ks C NET # Server CF Test Round ribe Tutorial DVD
s

If you like this website, please share


this site using g+1 button What are the different ways to replace
Recommend this on Google NULL values in SQL Server
This interview question is not that common. My friend faced this interview
question, when he attended an interview in London. My friend said we can use 
COALESCE() in SQL Server. Then the interviewer said, that's very good answer,
but do you know of any other way? 

Best software training institute in bangalore for SAP ABAP,
SAP BI, .Net, Informatica, Software Testing, Siebel CRM
I am Venkat and this is my website. I did training in Pragim
Get paid
Technologies and got job in Dell in less than a week. PRAGIM is the
for doing what you love
best S/W training institute in Bangalore.
Click here for Hyderabad Center Website
For further details please call 09900113931.
Put Ads on your blog with Adsense
Royal Challenge Sports Drin

LEARN MORE

Apart from using COALESCE(), there are 2 other ways to replace NULL values in
SQL Server. Let's understand this with an example.
 

I have a Table tblEmployee, as shown in the diagram below. Some of the
Employees does not have gender. All those employees who does not have
Gender, must have a replacement value of 'No Gender' in your query result.
Let's explore all the 3 possible options we have.
CLICK TO KNOW MORE

SAP BI Training in Bangalore
Best SAP BI Training institute in Bangalore,
Marathahalli. Real time project based training
provided by working software professionals
having more than 10 years of experience.
Informatica Training in Bangalore
Informatica training in bangalore delivered by
a real time software expert having 10 years
of experience. 
Siebel CRM Training in Bangalore
Best software training institute for Siebel CRM
training in Marathahalli, Bangalore. 
Software testing training institute in
bangalore

http://venkatsqlinterview.blogspot.in/2012/03/what­are­different­ways­to­replace­null.html 1/4
12/24/2016 SQL Server Interview Questions: What are the different ways to replace NULL values in SQL Server

Software testing training on real time projects
and placements. 
MSBI Training Institute in Bangalore
Best MSBI Training in Bangalore by an
expert. MSBI training on real time projects
and placements. 
Basic SQL Server Interview Questions

SQL Server Interview Questions on


Temporary Tables

SQL Server Interview Questions on Airtel Postpaid Plans


Indexes ‐ Part 1
Get MyPlan with Great Beneãts and
SQL Server Interview Questions on Packs. Browse for Details.
Indexes ‐ Part 2 www.airtel.in/myplan

What is the difference between


Having and Where clause Option 1 : Replace NULL values in SQL Server using ISNULL() function.

What is the difference between a Select Name, ISNULL(Gender,'No Gender') as Gender


Temporary Table and a Table Variable From tblEmployee

What is the use of COALESCE in SQL  


Server
Option 2 : Replace NULL values in SQL Server using CASE.
SQL Server Interview Questions on
triggers Select Name, Case  When Gender IS NULL Then 'No Gender' Else Gender End
as Gender
Difference between User Defined From tblEmployee
Function and Stored Procedure
 
SQL Server Interview Questions on
Views ‐ Part 1 Option 3 : Replace NULL values in SQL Server using COALESCE() function.

SQL Server Interview Questions on Select Name, Coalesce(Gender, 'No Gender') as Gender


Views ‐ Part 2 From tblEmployee

Basic SQL Server Interview Questions  


on Joins
These are the 3 options that I can think of at the moment. If you can think of any
Explain Inner Join with an example other option, please post it here.
Recommend this on Google
Explain Left Outer Join with an
example

Explain Right Outer Join with an 6 comments:


example

Explain Full Outer Join with an Anonymous July 24, 2012 at 5:53 AM
example
Using the ISNULL function ie
Explain Self Join with an example
Select Name, ISNULL(Gender,'No Gender') as Gender
What is the difference between Index From tblEmployee
Scan and Index Seek
only the first letter is updated ie it has to display as "No
Write a SQL Query to delete from a Gender" but displaying as N
table that is involved in a SQL join
Reply
What are the advantages of using
stored procedures Replies
What are the different ways to
Anonymous October 15, 2013 at 3:30 PM
replace NULL values in SQL Server
http://venkatsqlinterview.blogspot.in/2012/03/what­are­different­ways­to­replace­null.html 2/4
12/24/2016 SQL Server Interview Questions: What are the different ways to replace NULL values in SQL Server

Please check your 'Gender' column data type. make


SQL Server interview questions on sure your column length is greater than or equal to 9.
string manipulation functions

Write a Stored Procedure that takes Reply


column name as a parameter and
returns the result sorted by the
column that is passed
Nagesh Devaramani August 9, 2013 at 12:42 PM
What is deferred name resolution in
SQL Server? what is the difference between coalesce and isnull?
Reply

Replies

Manish September 9, 2013 at 3:04 AM


Coalesce is use for more than two columns where as
Isnull works only for two column. Also you can use
coalesce function in joining to get first not null value
from more than two different table.

Sangars Bhargav July 31, 2016 at 7:41 PM


the major difference is coalesce replaces the null
value with the first not null value among the
arguments whereas isnull replaces the null value with
specified replacement value

Reply

vijay negi January 15, 2016 at 12:23 PM


Some how iif() and nullif also try to do something
Reply

Enter your comment...

Comment as:  Select profile...

Publish
  Preview

http://venkatsqlinterview.blogspot.in/2012/03/what­are­different­ways­to­replace­null.html 3/4
12/24/2016 SQL Server Interview Questions: What are the different ways to replace NULL values in SQL Server

If you are aware of any other sql server questions asked in an


interview, please post them below. If you find anything missing or
wrong, please feel free to correct by submitting the form below.

Newer Post Home Older Post

Subscribe to: Post Comments (Atom)

 
Disclaimer ­ Terms of use ­ Contact Us

http://venkatsqlinterview.blogspot.in/2012/03/what­are­different­ways­to­replace­null.html 4/4

Вам также может понравиться