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
What are cursors in ms sql server?
write an SQL query to list the employees who joined in the month of January?
What are the options which must be set to allow the usage of optimistic models?
How to disable a login name in ms sql server?
What is shared lock?
Mention the differences between sql server and mysql.
How to change the data type of an existing column with "alter table" statements in ms sql server?
Explain the first normal form(1nf)?
Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting are possible?
What are the differences between “row_number()”, “rank()” and “dense_rank()”?
What is an example of a primary key?
Explain how does the report manager work in ssrs?
What is the recovery model? List the types of recovery model available in sql server?
What is dbcc updateusage?
 Explain what is sql override for a source taLle in a mapping?