How to write query to Delete the records in child table
and corresponding records in parent table

Answer Posted / surya

use this:

DELETE FROM childTable WHERE EXISTS(SELECT id FROM
parentTable WHERE parentTable .id = childTable .id where id = 1)

Is This Answer Correct ?    4 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are triggers? How many triggers you can have on a table? How to invoke a trigger on demand?

926


how to determine the service pack currently installed on sql server? : Sql server database administration

737


What are the disadvantages of merge replication?

967


What stored by the master? : sql server database administration

740


How you can move data or databases between servers and databases in sql server?

757






Can a table have 2 primary keys?

710


What are the different types of locks in the database?

645


What happens if strings are casted into wrong code pages in ms sql server?

820


Can primary key be a foreign key?

752


What is report rendering ?

131


Explain how would you store your query in an SSRS report or a Database server?

102


Why we need to use secondry database file? though, we can do same work using primary database file also.

6189


What are extended events in sql server?

668


Explain difference between cross join and full outer join?

736


How to generate create function script on an existing function?

772