SQL中MERGE关于更新、插入的一种用法
时间:2021-07-01 10:21:17
帮助过:4人阅读
@SJD_Code AS VARCHAR(
24)
DECLARE @SJD_Nendo AS VARCHAR(
4)
MERGE INTO D_SJD
USING (SELECT @SJD_Code [SJD_Code],
@SJD_Nendo [SJD_Nendo]) insertData
ON D_SJD.
[SJD_Code] = insertData.SJD_Code
WHEN MATCHED
THEN
UPDATE SET [SJD_Nendo] = insertData.
[SJD_Nendo]
WHEN NOT MATCHED
THEN
INSERT (
[SJD_Code],
[SJD_Nendo] )
VALUES ( insertData.
[SJD_Code],
insertData.[SJD_Nendo] );
还是比较方便的
SQL中MERGE关于更新、插入的一种用法
标签: