MERGE statement

MERGE TARGET.dbname.dbo.tablename AS target
USING SOURCE.dbname.dbo.tablename AS source ON

    source.field1 = target.field1 COLLATE Lithuanian_BIN AND
    source.field2 = target.field2 AND
    source.field3 = target.field3 AND
    source.field4 = target.field4

        WHEN NOT MATCHED THEN INSERT (field1, field2, field3, field4)
        VALUES (source.field1, source.field2, source.field3, source.field4)

            WHEN NOT MATCHED BY SOURCE THEN
            DELETE

                OUTPUT $action, DELETED.*, INSERTED.*;