adspace
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 the difference between upgrade and migration in sql server?
How to convert character strings into numeric values?
Is there any performance difference between if exists (select null from table) and if exists (select 1 from table)?
What is subquery? Explain the properties of a subquery?
What is sql server query analyzer?
If you're given a raw data table, how would perform etl (extract, transform, load) with sql to obtain the data in a desired format?
What are the risks of storing a hibernate-managed object in a cache? How do you overcome the problems?
How can we solve concurrency problems?
What is temporary table in sql server? Why we use temp table?
How to provide default values to function parameters?
What is acid mean in sql server?
What are the properties of the transaction?
Can one drop a column from a table?
How to convert numeric expression data types using the cast() function?
What is standby servers? Explain types of standby servers.