Merging table data
MERGE statements can perform update and insert operations on a target table based on the results of a join with a source data set.
	
MERGE statements can perform update and insert operations on a target table based on the results of a join with a source data set. The join can match a source row with only one target row; otherwise, the database returns an error.
MERGE has the following syntax:
MERGE INTO target-table USING source-dataset ON  join-condition
matching-clause[ matching-clause ]
Merge operations have at least three components:
- 
The target table on which to perform update and insert operations. MERGEtakes an X (exclusive) lock on the target table until the merge operation is complete.
- 
Join to another data set, one of the following: a table, view, or subquery result set. 
- 
One or both matching clauses: WHEN MATCHED THEN UPDATE SETandWHEN NOT MATCHED THEN INSERT.