我对编程有点陌生。
当我执行查询时出现此消息:
消息 156,级别 15,状态 1,第 1 行
关键字“As”附近的语法不正确。
你能告诉我它有什么问题吗?
MERGE Table_2 As target
USING Table_1 AS SOURCE
ON (TARGET.ID = SOURCE.ID)
WHEN MATCHED AND TARGET.FirstName <> SOURCE.FirstName
OR TARGET.LastName <> SOURCE.LastName THEN
UPDATE SET TARGET.FirstName = SOURCE.FirstName,
TARGET.LastName = SOURCE.LastName
WHEN NOT MATCHED BY TARGET THEN
INSERT (ID, FirstName, LastName)
VALUES (SOURCE.ID, SOURCE.FirstName, SOURCE.LastName)
WHEN NOT MATCHED BY SOURCE THEN
DELETE