Skip to content
Advertisement

delete values from depending tables using merge

I am trying to match rows from a table in source and destination db tables. I am able to delete that row which is present in dest table and not present in source table. However I also need to delete its dependent rows in other tables inside the dest db. Is there a way I can achieve this inside a merge.

Merge statement goes like this below.

See illustration below.

Thanks in advance.

Advertisement

Answer

Use a cascading deletion as Nenad Zivkovic suggested.

Here are a couple relevant links that provide some potential answers:

How to delete from source using merge command

Delete rows from multiple tables using a single sql query

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement