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

Explain what are page splits? : SQL Server Architecture

1054


How can you insert null values in a column while inserting the data?

1275


Can we insert data into a view?

1129


What is the order in which the sql query is executed?

937


List few advantages of stored procedure.

981


Explain the benefits of user-defined functions?

1052


What is a cursor, index in sql?

1067


What is the difference between deallocate cursor and close cursor?

1249


Can you tell me some of the common replication dmv's and their use? : sql server replication

919


Would you store your query in a ssrs report or a database server? State the reason why?

152


What is open database communication (odbc)?

1056


If the job running very slow what is the action you do

1886


what are questions asked in TCS for database tester (sqlserver)for 2-3 exp?

5920


What is amo? : sql server analysis services, ssas

1086


Can we add a cpu to sql server?

1003