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 sql service broker?

1020


Explain the use of containers in ssis?

1013


How many types of the database links?

1115


What is the difference between mysql and mysqli?

1283


Describe different Processing Modes offered by SSRS?

256


Explain four layers of abstraction microsoft architectured?

147


Explain iaas, paas and saas?

92


what is a transaction? : Sql server database administration

1047


What is a unique index?

970


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

133


How do I run sql server 2014?

1054


What are “lock” hints?

1102


What is relationship? What number of sorts of relationship are there?

1220


How to create a view and a stored procedure in ms sql server using "create view/procedure" statements?

1070


How to send email from database?

1069