You are on page 1of 4

12/24/2016 SQL Server Interview Questions: Delete from tables involved in a SQL Join

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 Delete from tables involved in a SQL Join
+2   Recommend this on Google This question is not asked that often in an interview, but you may have to write a
query to delete from tables that are involved in a SQL join in your day to day job
}
routine as a SQL Developer. 

{
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.

Let me explain you the question first. Consider the Employees and
Departments tables below. 

SAP BI Training in Bangalore
Best SAP BI Training institute in Bangalore,
Marathahalli. Real time project based training
I want you to write a query using joins which will give me the list of all HR
provided by working software professionals
Department employees. The output should be as shown below.
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/07/delete­from­tables­involved­in­sql­join.html 1/4
12/24/2016 SQL Server Interview Questions: Delete from tables involved in a SQL Join

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  
To do this we will write a query using joins as shown below.
What is the difference between a Select E.Name as [Employee Name],D.Name as [Department Name]
Temporary Table and a Table Variable from Employees E
Inner Join Departments D
What is the use of COALESCE in SQL On E.DeptId = D.Id
Server Where D.Name = 'HR'

SQL Server Interview Questions on Now I want you to write a query, that deletes all the HR department


triggers employees. To do this we have to join Employees and Departments tables and
usually we will be tempted to write the query as shown below, but this query will
Difference between User Defined not execute and will give a syntax error.
Function and Stored Procedure
Incorrect SQL Delete Query to delete from multiple tables invloved in a SQL
SQL Server Interview Questions on join
Views ‐ Part 1 Delete From Employees E
Inner Join Departments D
SQL Server Interview Questions on On E.DeptId = D.Id
Views ‐ Part 2 Where D.Name = 'HR'

Basic SQL Server Interview Questions The query below shows the correct syntax for issuing a SQL delete that


on Joins involves a SQL join.
Delete E From (Employees E
Explain Inner Join with an example Inner Join Departments D
On E.DeptId = D.Id
Explain Left Outer Join with an and D.Name = 'HR')
example
The following syntax is also valid and has the same effect.
Explain Right Outer Join with an Delete Employees From
example (
Employees join Departments
Explain Full Outer Join with an on Employees.DeptId = Departments.Id
example )
where Departments.Name = 'HR'
Explain Self Join with an example +2   Recommend this on Google

What is the difference between Index


Scan and Index Seek
5 comments:
Write a SQL Query to delete from a
table that is involved in a SQL join
Anonymous September 7, 2012 at 12:42 PM
What are the advantages of using
stored procedures how to delete duplicate records from table.
Reply
What are the different ways to
replace NULL values in SQL Server
http://venkatsqlinterview.blogspot.in/2011/07/delete­from­tables­involved­in­sql­join.html 2/4
12/24/2016 SQL Server Interview Questions: Delete from tables involved in a SQL Join

SQL Server interview questions on Replies


string manipulation functions
Anonymous October 15, 2015 at 1:10 AM
Write a Stored Procedure that takes Using CTC statement in Sql Server
column name as a parameter and
with tbltem as(
returns the result sorted by the
column that is passed
Select Row_Number() over(Partition by Name order
by Name) as RowNumber,* from Employee)Delete
What is deferred name resolution in from tbltem where RowNumber>1
SQL Server?
Reply

Anonymous May 13, 2013 at 1:20 PM


delete Employees
from Employees
t1 inner join Departments t2 on t1.DeptId = t2.Id
where t2.Name = 'HR'
Reply

Anonymous October 23, 2013 at 2:09 PM


@Anonymous May 13, 2013 at 1:20 PM:

Your query deletes all the matched records. But in the case
where more than one of the same record if exists, deletion
should be done leaving one record. In that case how should we
perform deletion?
Reply

umairumair razzaq January 6, 2014 at 10:58 PM


Some Friend asking about duplicate deletion.
I think, Check your relation could be irrelevant or your joining
could have mistake if you are working with Relation.
Reply

Enter your comment...

Comment as:  Select profile...

Publish
  Preview

http://venkatsqlinterview.blogspot.in/2011/07/delete­from­tables­involved­in­sql­join.html 3/4
12/24/2016 SQL Server Interview Questions: Delete from tables involved in a SQL Join

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/07/delete­from­tables­involved­in­sql­join.html 4/4

You might also like