所谓的潇洒

导航

SqlServer的Merge语句

CREATE TABLE #TEMP(Id INT,Name NVARCHAR(100));

MERGE INTO Student T USING #TEMP S ON T.Id=S.Id

WHEN MATCHED THEN UPDATE SET Name=S.Name

WHEN NOT MATCHED THEN INSERT VALUES(S.Id,S.HolidayDate)

WHEN NOT MATCHED BY SOURCE AND T.Id BETWEEN 1 AND 31 THEN DELETE;

 

posted on 2021-07-27 14:22  所谓的潇洒  阅读(69)  评论(0编辑  收藏  举报