When deleting data that exists in both tables.

DELETE FROM TABLE1 A
WHERE EXISTS(
SELECT 1 FROM TABLE2 B
WHERE A.KEY1=B.KEY2
AND A.KEY2=B.KEY2)

When updating a field from another table.

UPDATE C
SET C.UPDATEFIELD=D.UPDATEFIELD
FROM TABLE1 C INNER JOIN TABLE2 D ON C.KEY1=D.KEY1 WHERE C.KEY2=’PARAMETER’

Advertisements