Implementing MERGE Functionality
Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).
A database may need to perform either an insert of an update, depending on whether a particular row already exists in the database.
Without using the MERGE statement, the following is one approach you can use in Transact-SQL:
UPDATE mytable SET col=@somevalue WHERE myPK = @parm IF @@ROWCOUNT = 0 INSERT mytable (columns) VALUES (@parm, @other values)
Another Transact-SQL method to implement a merge:
For a natively compiled stored procedure