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 sql service broker?
Explain the use of containers in ssis?
How many types of the database links?
What is the difference between mysql and mysqli?
Describe different Processing Modes offered by SSRS?
Explain four layers of abstraction microsoft architectured?
Explain iaas, paas and saas?
what is a transaction? : Sql server database administration
What is a unique index?
Explain how would you store your query in an SSRS report or a Database server?
How do I run sql server 2014?
What are “lock” hints?
What is relationship? What number of sorts of relationship are there?
How to create a view and a stored procedure in ms sql server using "create view/procedure" statements?
How to send email from database?