This question already has an answer here:
I am using ms SQL server. I have 2 tables. Table a and b. Table 'A' contains col 'A' and col 'B'(foreign key) and table 'B' contains details relating to that col 'B'.I want to delete two tables based on col 'A' now. Please help me out of this
DELETE T1, T2 FROM T1 INNER JOIN T2 ON T1.key = T2.key WHERE condition
Notice that you put table names T1 and T2 between DELETE and FROM. If you omit the T1 table, the DELETE statement only deletes records in the T2 table, and if you omit the T2 table, only records in the T1 table are deleted.
The join condition T1.key = T2.key specifies the corresponding records in the T2 table that need be deleted.
The condition in the WHERE clause specifies which records in the T1 and T2 that need to be deleted.