You are on page 1of 4

12/24/2016 SQL Server Interview Questions: Full Outer Join in SQL Server with an example

2   More    Next Blog» Create Blog   Sign In

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

If you like this website, please share


this site using g+1 button Full Outer Join in SQL Server with an
+2   Recommend this on Google example
{
Take: [“the”],
Android:
“course”
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
Technologies and got job in Dell in less than a week. PRAGIM is the
best S/W training institute in Bangalore.
Click here for Hyderabad Center Website
For further details please call 09900113931.

Inner Join and left join are the most commonly used joins in real time projects.
It is very important that you understand the basics of joins before reading this
article. Please read the articles below if you have not done so already. 
1. Basics of Joins in SQL Server
2. Inner Join
3. Left Join
4. Right Join 
Now, let us understand Full Outer join with an example.

Create 2 tables Company and Candidate. Use the script below to create these
tables and populate them. CompanyId column in Candidate Table is a foreign key
referencing CompanyId in Company Table.

CREATE TABLE Company
(
    CompanyId TinyInt Identity Primary Key,
SAP BI Training in Bangalore     CompanyName Nvarchar(50) NULL
Best SAP BI Training institute in Bangalore, )
Marathahalli. Real time project based training GO
provided by working software professionals
having more than 10 years of experience. INSERT Company VALUES('DELL')
Informatica Training in Bangalore INSERT Company VALUES('HP')
Informatica training in bangalore delivered by INSERT Company VALUES('IBM')
a real time software expert having 10 years INSERT Company VALUES('Microsoft')
of experience.  GO
Siebel CRM Training in Bangalore
Best software training institute for Siebel CRM CREATE TABLE Candidate
training in Marathahalli, Bangalore.  (
Software testing training institute in     CandidateId tinyint identity primary key,
bangalore     FullName nvarchar(50) NULL,

http://venkatsqlinterview.blogspot.in/2011/05/full­outer­join­in­sql­server­with.html 1/4
12/24/2016 SQL Server Interview Questions: Full Outer Join in SQL Server with an example

Software testing training on real time projects     CompanyId tinyint REFERENCES Company(CompanyId)
and placements.  )
MSBI Training Institute in Bangalore GO
Best MSBI Training in Bangalore by an
expert. MSBI training on real time projects INSERT Candidate VALUES('Ron',1)
and placements.  INSERT Candidate VALUES('Pete',2)
Basic SQL Server Interview Questions INSERT Candidate VALUES('Steve',3)
INSERT Candidate VALUES('Steve',NULL)
SQL Server Interview Questions on INSERT Candidate VALUES('Ravi',1)
Temporary Tables INSERT Candidate VALUES('Raj',3)
INSERT Candidate VALUES('Kiran',NULL)
SQL Server Interview Questions on GO
Indexes ‐ Part 1

SQL Server Interview Questions on


Indexes ‐ Part 2

What is the difference between


Having and Where clause

What is the difference between a


Temporary Table and a Table Variable

What is the use of COALESCE in SQL


Server Airtel Postpaid Plans
SQL Server Interview Questions on Get MyPlan with Great Bene‫ﴖ‬ts and
triggers Packs. Browse for Details.
www.airtel.in/myplan
Difference between User Defined
Function and Stored Procedure
If you want to select all the rows from the LEFT Table ( In our example
SQL Server Interview Questions on Candidate Table ) plus all the rows from the RIGHT table ( In our example
Views ‐ Part 1 Company Table ) , then we use FULL OUTER JOIN. A query involving a FULL
OUTER JOIN for the Candidate and Company Table is shown below.
SQL Server Interview Questions on
Views ‐ Part 2 SELECT Cand.CandidateId, Cand.FullName, Cand.CompanyId,
Comp.CompanyId, Comp.CompanyName
Basic SQL Server Interview Questions FROM Candidate Cand
on Joins FULL OUTER JOIN Company Comp
ON Cand.CompanyId = Comp.CompanyId
Explain Inner Join with an example
If we run the above query the output will be as shown in below. If you look at the
Explain Left Outer Join with an out put, we now got 8 rows. All the rows from the Candidate Table and all the
example rows from the Company Table.

Explain Right Outer Join with an


example

Explain Full Outer Join with an


example

Explain Self Join with an example

What is the difference between Index


Scan and Index Seek

Write a SQL Query to delete from a Full Outer Join Result


table that is involved in a SQL join
Instead of using FULL OUTER JOIN keyword we can just use FULL JOIN
What are the advantages of using keyword as shown below. FULL OUTER JOIN or FULL JOIN means the same.
stored procedures
SELECT Cand.CandidateId, Cand.FullName, Cand.CompanyId,
What are the different ways to Comp.CompanyId, Comp.CompanyName
replace NULL values in SQL Server FROM Candidate Cand
http://venkatsqlinterview.blogspot.in/2011/05/full­outer­join­in­sql­server­with.html 2/4
12/24/2016 SQL Server Interview Questions: Full Outer Join in SQL Server with an example

FULL JOIN Company Comp
SQL Server interview questions on ON Cand.CompanyId = Comp.CompanyId
string manipulation functions
If you can think of any other sql server interview questions please post
Write a Stored Procedure that takes them as comments, so they will be useful to other users like you. This will
column name as a parameter and be a great help from your side to improve this site.
returns the result sorted by the
+2   Recommend this on Google
column that is passed

What is deferred name resolution in


SQL Server? 4 comments:

Ram Chowdary May 25, 2012 at 3:53 AM


What is the difference between join & Union?
Reply

Replies

sailaja bhamidipaty March 27, 2015 at 1:12 PM


The difference between join & union are:
Join the tables based on condition like inner or outer
joins. Here columns are not specific order.
For Union combining two or more select statements
into one result set but it has to follow three rules like
a.order of columns should be same
b. columns has same data type
c. Number of columns should be same.

Reply

Anonymous July 26, 2014 at 5:31 AM


Wha is the difference between right join and full outer join ..?
here both are giving same values ... bit confusing
Reply

Replies

sailaja December 14, 2015 at 3:03 PM


Right join is the matching rows in both the Left and
right tables plus non matching rows in the Right table.
Full join is the matching rows in both Left and Right
tables plus Non‐matching rows in both Left and right
tables.

Reply

http://venkatsqlinterview.blogspot.in/2011/05/full­outer­join­in­sql­server­with.html 3/4
12/24/2016 SQL Server Interview Questions: Full Outer Join in SQL Server with an example

Enter your comment...

Comment as:  Select profile...

Publish
  Preview

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/2011/05/full­outer­join­in­sql­server­with.html 4/4

You might also like