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
between cast and convert which function would you prefer and why?
How extra digits are handled with numeric data type literals?
You want to check the syntax of a complicated update sql statement without executing it. What command should you use?
How to use column default values in insert statements in ms sql server?
What is compound operators?
Can group by be used without aggregate functions?
Explain Geometry datatype in sql server 2008 with example
Explain Geography datatype in SQL Server
What are binary string data types in ms sql server?
What is a transact-sql statement batch in ms sql server?
What are user-defined functions (udfs) in sql server?
How many levels of sp nesting is possible?
Show Practically Sql Server Views are updatable?
What is auditing in sql server?
How to return the second 5 rows in ms sql server?