Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is query processing?

942


Tell me what is log shipping?

977


Define primary key?

1140


How data can be copied from one table to another table?

950


Explain about unique identifier data type in sql server?

920


Is null vs coalesce?

886


What are trace flags?

1033


Can we use trigger new in before insert?

922


How to achieve Paging of records in SQL SERVER?

1102


What is the partitioning method?

1018


Does index slows down insert statements?

1002


Does full backup break log chain?

963


Is it possible to call a stored procedure within a stored procedure?

979


Explain how would you store your query in an SSRS report or a Database server?

128


What is a transact-sql statement batch in ms sql server?

1019