How to write query to Delete the records in child table
and corresponding records in parent table

Answer Posted / dileep

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 ?    9 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a non equi join?

733


What are the different Topologies in which Replication can be configured?

856


What is change data capture (cdc) in sql server 2008?

749


What are the differences between user defined functions and stored procedures?

732


What is the maximum number of instances in 32 bit and 64 bit sql server 2012?

733






Explain the benefits of user-defined functions?

727


What is filestream?

739


What do you understand by replication in sql server?

744


What is the full meaning of dml?

712


What is #temp and @table variable in SQL server?

758


How to create a store procedure with encryption?

697


What is thr feature of change data capture?

670


Define self join in sql server joins?

692


What are the source of constraints?

664


Can an entity have two primary keys?

720