只需要提供:
1.目标表 (target table)
2.数据源表 (source table)
3.连接条件
4.当行匹配时执行的更新语句
5.不匹配时更新语句
MERGE dbo.SomeTable AS target
USING dbo.AnotherTable AS source
ON (target.[UserName] = source.[UserName])
WHEN MATCHED THEN
UPDATE SET Name = source.Name,
Col = source.Col
WHEN NOT MATCHED THEN
INSERT (Col1, Col2, ...., ColN)
VALUES (source.Val1, source.Val2, ...., source.ValN);