How to write query to Delete the records in child table
and corresponding records in parent table
Answer Posted / krishna evsg
With help of temporary tables , we can do it made easy
create table #temp_ParentIDs
(
ID int
)
GO
Insert into #temp_ParentIDs
(ID)
select Parent_id from child_tab
GO
delete from Child_tab
GO
delete from parent_tab where parent_Id In(select * from
#temp_ParentIDs)
GO
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
What is query processing?
Tell me what is log shipping?
Define primary key?
How data can be copied from one table to another table?
Explain about unique identifier data type in sql server?
Is null vs coalesce?
What are trace flags?
Can we use trigger new in before insert?
How to achieve Paging of records in SQL SERVER?
What is the partitioning method?
Does index slows down insert statements?
Does full backup break log chain?
Is it possible to call a stored procedure within a stored procedure?
Explain how would you store your query in an SSRS report or a Database server?
What is a transact-sql statement batch in ms sql server?