Vous êtes sur la page 1sur 6

12/24/2016 SQL Server Interview Questions: Basic SQL Server Interview Questions on Joins

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 Basic SQL Server Interview Questions on
+2   Recommend this on Google Joins
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.

Royal Challenge Sports Drin


What are the different types of joins available in sql server?
There are 3 different types of joins available in sql server, and they are
1. Cross Join 
2. Inner Join or Join 
3. Outer Join

Outer Join is again divided into 3 types as shown below.
1. Left Outer Join or Left Join 
2. Right Outer Join or Right Join 
3. Full Outer Join or Full Join 

You might have heard about self join, but self join is not a different type of join. A
self join means joining a table with itself. We can have an inner self join or outer
self join. Read this sql server interview question, to understand self join in a
greater detail.
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/2011/05/basic­sql­server­interview­questions­on.html 1/6
12/24/2016 SQL Server Interview Questions: Basic SQL Server Interview Questions on Joins

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


Indexes ‐ Part 1

SQL Server Interview Questions on


Indexes ‐ Part 2

What is the difference between


Having and Where clause What is cross join. Explain with an example?
Let us understand Cross Join with an example. Create 2 tables Company and
What is the difference between a Candidate. Use the script below to create these tables and populate them.
Temporary Table and a Table Variable CompanyId column in Candidate Table is a foreign key referencing CompanyId in
Company Table.
What is the use of COALESCE in SQL
Server CREATE TABLE Company
(
SQL Server Interview Questions on     CompanyId TinyInt Identity Primary Key,
triggers     CompanyName Nvarchar(50) NULL
)
Difference between User Defined GO
Function and Stored Procedure
INSERT Company VALUES('DELL')
SQL Server Interview Questions on INSERT Company VALUES('HP')
Views ‐ Part 1 INSERT Company VALUES('IBM')
INSERT Company VALUES('Microsoft')
SQL Server Interview Questions on GO
Views ‐ Part 2
CREATE TABLE Candidate
Basic SQL Server Interview Questions (
on Joins     CandidateId tinyint identity primary key,
    FullName nvarchar(50) NULL,
Explain Inner Join with an example     CompanyId tinyint REFERENCES Company(CompanyId)
)
Explain Left Outer Join with an GO
example
INSERT Candidate VALUES('Ron',1)
Explain Right Outer Join with an INSERT Candidate VALUES('Pete',2)
example INSERT Candidate VALUES('Steve',3)
INSERT Candidate VALUES('Steve',NULL)
Explain Full Outer Join with an INSERT Candidate VALUES('Ravi',1)
example INSERT Candidate VALUES('Raj',3)
INSERT Candidate VALUES('Kiran',NULL)
Explain Self Join with an example GO

What is the difference between Index A cross join produces the Cartesian product of the tables involved in the join.


Scan and Index Seek The size of a Cartesian product result set is the number of rows in the first table
multiplied by the number of rows in the second table. A query involving a
Write a SQL Query to delete from a CROSS JOIN for the Candidate and Company Table is shown below.
table that is involved in a SQL join
SELECT  Cand.CandidateId,Cand.FullName,Cand.CompanyId,
What are the advantages of using Comp.CompanyId,Comp.CompanyName
stored procedures FROM Candidate Cand
CROSS JOIN Company Comp
What are the different ways to
replace NULL values in SQL Server
http://venkatsqlinterview.blogspot.in/2011/05/basic­sql­server­interview­questions­on.html 2/6
12/24/2016 SQL Server Interview Questions: Basic SQL Server Interview Questions on Joins

If we run the above query, we produce the result set shown in the image
SQL Server interview questions on below.
string manipulation functions

Write a Stored Procedure that takes


column name as a parameter and
returns the result sorted by the
column that is passed

What is deferred name resolution in


SQL Server?

Key Points to remember about CROSS JOIN. 
1. A cross join produces the Cartesian product of the tables involved in the
join.This mean every row in the Left Table is joined to every row in the Right
Table. Candidate is LEFT Table and Company is RIGHT Table. In our example
we have 28 total number of rows in the result set. 7 rows in the Candidate table
multiplied by 4 rows in the Company Table. 

2. In real time scenarios we rarley use CROSS JOIN. Most often we use either
INNER JOIN or LEFT OUTER JOIN. 

3. CROSS JOIN does not have an ON clause with a Join Condition. All the other
JOINS use ON clause with a Join Condition. 

4. Using an ON clause on a CROSS JOIN would generate a syntax error. 

Note: Understanding the above key points will help you answer any follow up
interview questions on cross join in sql server.

If you can think of any other sql server interview questions please post
them as comments, so they will be useful to other users like you. This will
be a great help from your side to improve this site.
+2   Recommend this on Google

9 comments:

http://venkatsqlinterview.blogspot.in/2011/05/basic­sql­server­interview­questions­on.html 3/6
12/24/2016 SQL Server Interview Questions: Basic SQL Server Interview Questions on Joins

Anonymous May 3, 2013 at 6:24 AM


what are the global variables in sql server?what is the use of it?
Reply

Anonymous June 25, 2013 at 11:29 PM


Hello Venket, I would like to admire and thank you for what
you are doing ! You have been a vessel of God helping those
who can not get education for free and giving your time, life for
us and it is really a tremendous virtue. May God bless you .
I have a question though :

could you explain what dynamic sql is with example as usual ?


Reply

Replies

Anonymous January 21, 2016 at 4:38 AM


join batch

Reply

Jayashree Krishnamurthy May 8, 2014 at 4:06 AM


Hi Venkat, thanks for sharing this wonderful question batches.
It really helped me to take up an interview yday. i am not sure
whether i am into the job or not but i felt happy tht i
understood some basics which i have never paid attention
before. Thanks to you.

I would like to add one more question of the difference between


UNION and UNION ALL. Please post this difference too.

Thanks
Jay.
Reply

Replies

Anonymous May 25, 2016 at 7:12 AM


Union will remove the duplicates and display a Sorted
Table where as in Union All displays duplicate data in
an Unsorted output. Bcoz of the Sorting Union is
slower in terms of execution when compared to Union
All.

Reply

Basha Sk June 10, 2014 at 3:46 AM


how to retrieve data from more then 2 tables.
Reply
http://venkatsqlinterview.blogspot.in/2011/05/basic­sql­server­interview­questions­on.html 4/6
12/24/2016 SQL Server Interview Questions: Basic SQL Server Interview Questions on Joins

Reply

Replies

Deepak Kashyap September 11, 2014 at 4:24 AM


with the help of joins

Reply

suma August 7, 2014 at 6:46 AM


hi venkat can u tell me how to delete duplicate rows in a table?
Reply

Replies

Deepak Kashyap September 11, 2014 at 4:28 AM


Hey you can delete duplicate records with the help of
CTE in sql, Here the example ‐:

WITH cte AS
(
SELECT *,ROW_NUMBER() OVER(PARTITION BY
emp_name ORDER BY emp_name)'RowRank'
FROM Employee_Test
)
DELETE FROM cte WHERE RowRank > 1

Reply

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

http://venkatsqlinterview.blogspot.in/2011/05/basic­sql­server­interview­questions­on.html 5/6
12/24/2016 SQL Server Interview Questions: Basic SQL Server Interview Questions on Joins

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/basic­sql­server­interview­questions­on.html 6/6

Vous aimerez peut-être aussi