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                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
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 write query to  Delete the records in child table 
and corresponding records in parent table
 Question Submitted By :: Tester
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How to write query to Delete the records in child table and corresponding records in parent table
Answer
# 1
delete from child_table, parent_table where
child_table.parent_id=parent_table.parent_id
 
Is This Answer Correct ?    6 Yes 10 No
Vaishali
 
  Re: How to write query to Delete the records in child table and corresponding records in parent table
Answer
# 2
Hi vaishali have u executed the query it is not working
 
Is This Answer Correct ?    4 Yes 3 No
Tester
 
 
 
  Re: How to write query to Delete the records in child table and corresponding records in parent table
Answer
# 3
delete from child_table where values=...
on delete cascade..
U have to set the foreign  key as the parent super key
 
Is This Answer Correct ?    3 Yes 2 No
Arijitnit
[Home]
 
  Re: How to write query to Delete the records in child table and corresponding records in parent table
Answer
# 4
Better you create a Trigger on child table like this one

CREATE TRIGGER trDelTrigger ON [dbo].[ChildTable] 
FOR  DELETE 
AS
DELETE FROM ParentTable WHERE ParentTable.IdColumn=
(SELECT Deleted.IdColumn FROM Deleted)
 
Is This Answer Correct ?    1 Yes 3 No
Dileep
 
  Re: How to write query to Delete the records in child table and corresponding records in parent table
Answer
# 5
I think using ON DELETE CASCADE we can delete  the records 
from both child and parent table
 
Is This Answer Correct ?    1 Yes 1 No
Satyanarayana
 
  Re: How to write query to Delete the records in child table and corresponding records in parent table
Answer
# 6
create table employee(id int references authors(au_id) ON
DELETE CASCADE,firstname(30))



this is chilld table .in this query use on first child table
constraints values delete next parent table constrains value
delete ...  this is   ON DELETE CASCADE CONCEPT
 
Is This Answer Correct ?    4 Yes 3 No
Krishnakumar
 
  Re: How to write query to Delete the records in child table and corresponding records in parent table
Answer
# 7
delete from c from child c inner join parent
on c.childid = parentid
 
Is This Answer Correct ?    1 Yes 5 No
Zackziss
 
  Re: How to write query to Delete the records in child table and corresponding records in parent table
Answer
# 8
delete details  from details inner join master on 
details.keyid=master.keyid
 
Is This Answer Correct ?    0 Yes 0 No
Sanjay
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
What is normalization?  6
Say if we have a table that contains only a single column , say OrderID, which has IDENTITY attribute defined on it. So how can we insert data in this table. I am reframing my question, that how can we make the table to increment the column "OrderID" value several times???  3
can primery key be a non clustered index?  8
can you any body tell me while running BCP Out in instance in sql server 2000 is getting error. Error = [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.?  1
Wht is SQL Injection Attack ?  1
please tell me the query to get details of the employee having the second largest salary 247Customer8
Which system tables contain information on privileges granted and privileges obtained  1
is it possible to use a variable in a query with the IN clause (a,b,c..z), without getting quotes or conversion errors?  2
What is transaction ? Give me one example. Melstar7
how insert selected column only ? Robert-Half2
There is table like Events...in that name ,startdate ,enddate,location are the column names write a stored Procedure for this table to get events by Months "GetEventsByMonths"  1
hi i gone though satyam interview. what is Acid Properties? Satyam2
Can a stored procedure call another stored procedure. If yes what level and can it be controlled?  2
what is the order of execution of where,having,group by in select stement Tanla-Solutions5
What is the difference between DTS and SSIS? Allianz3
Using query analyzer, name 3 ways you can get an accurate count of the number of records in a table? eFunds5
hi, how to match retrieve the unmatched records from 2 tables in which we dont have any primary key. example : table1 has 1,2,3,4,5 and table2 has 1,2,3,4,5,6,7,8,9,10 and i want the numbers from 6 to 10 to be displayed and should not come as null. i need the numbers. please reply as soon as possible.  2
What are tasks? Wipro1
Hi Friends, I have a table in which there are thousands of records and in city field there is NULL value for all records now i want to change that null value with distinct values in each record say delhi, bihar, agra, jaipur etc, what will be the query for that????? its not possible to update thousands of records one by one. is there any alternative ...? Plz help ... its urgent Thanx in advance  1
what is difference between having and where clause ?  2
 
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