The SQL Server Merge statement with examples and syntax.

MERGE dbo.TargetTable tgt   -- Target Table
USING dbo.SourceTable src   -- Source Table
ON tgt.ID = src.ID          -- Main comparison criteria
WHEN MATCHED                -- When ID's exist in both tables
    -- DO SOMETHING
WHEN NOT MATCHED            -- When ID's from Source do not exist in Target
    -- DO SOMETHING
WHEN NOT MATCHED BY SOURCE  -- When ID's from Target do not exist in Source
    -- DO SOMETHING