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
Give a example to search fr a string in all stored procedure in sql server.
what is a mixed extent? : Sql server administration
What is used to replicate sessions between instances in coldfusion clusters?
How to create a login account in ms sql server to access the database engine using "create login" statements?
What is query processing?
How to rebuild indexes with alter index ... Rebuild?
Explain what is dbcc?
Which rendering formats are affected by the pagesize properties?
What is query optimization process?
can a database be shrunk with users active? : Sql server administration
Why should one not prefix user stored procedures with ‘sp_’?
Every night you run a full backup after every 3 three hours you make a differential backup every hour you make an incremental backup in a worst-case scenario, how much work you can lose?
What do you understand by integration services in sql server?
How do I connect to sql server database?
when you create a database how is it stored? : Sql server database administration