这种模式称为UPSERT。现代的方法是在SQL Server
2008中使用MERGE,例如
MERGE INTO Application_Type_Table AS target USING ( VALUES (@RecordID, @TestValue) ) AS source (ID, ApplicationType) ON target.ID = source.IDWHEN MATCHED THEN UPDATE SET ApplicationType = source.ApplicationTypeWHEN NOT MATCHED THEN INSERT (ID, ApplicationType) VALUES (ID, ApplicationType);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)