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
Explain what are page splits? : SQL Server Architecture
How can you insert null values in a column while inserting the data?
Can we insert data into a view?
What is the order in which the sql query is executed?
List few advantages of stored procedure.
Explain the benefits of user-defined functions?
What is a cursor, index in sql?
What is the difference between deallocate cursor and close cursor?
Can you tell me some of the common replication dmv's and their use? : sql server replication
Would you store your query in a ssrs report or a database server? State the reason why?
What is open database communication (odbc)?
If the job running very slow what is the action you do
what are questions asked in TCS for database tester (sqlserver)for 2-3 exp?
What is amo? : sql server analysis services, ssas
Can we add a cpu to sql server?