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

How to delete an existing database user?

1001


What is transactional replication?

944


How to restore performance issues and how to check?

1986


what is an extended stored procedure? Can you instantiate a com object by using t-sql? : Sql server database administration

1001


What are the differences between ms sql server & oracle?

1036


What is an index in sql?

988


Can you pass expressions to function parameters?

1085


How do I open a .db file?

1022


What is wide table?

933


What are different types of subquery?

1214


What is scd (slowly changing dimension)? : sql server analysis services, ssas

994


what is a self join? : Sql server database administration

1013


What Is Rdbms?

1132


How do I get to sql server configuration manager?

992


What is t-sql script to take database offline – take database online.

1061