Remove only the records that don't don't exist before Update - SQL Server 2005
Posted on 2008-10-11
I am updating Table2 from Table1 with the following synatax:
SET col1 = t1.col1, col2 = t1.col2, col3 = t1.col3
FROM Table1 t1 INNER JOIN
Table2 t2 ON t1.ID = t2.ID
This works great to update existing records...
I would like to remove any records in Table2 that do not exist in Table1 before the update.
In other words: Table1 will always be the full record range of Table2 unless there was a record removed from Table1. I always want to make sure that deleted records from Table1 are also deleted in Table2 upoh each update.
Does anyone know how to do this?