TSQL Delete on join

Delete statement on join:

Some time you need to delete a table on join.
This example will help you to run delete statement on sql join.

Example:

DELETE table1
FROM
table1 t1
JOIN
table2 t2 ON t1.IDCOL=t2.IDCOL

This T-SQL is checking TABLE2, If records exists then delete TABLE1. Weather IDCOL is already there in TABLE2 or not?

Advertisements