O'Reilly logo

Microsoft® SQL Server 2012 Unleashed by Alex T. Silverstein, Chris Gallelli, Paul T. Bertucci, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

MERGE Statement

In versions of SQL Server prior to SQL Server 2012, if you had a set of data rows in a source table that you wanted to synchronize with a target table, you had to perform at least three operations: one scan of the source table to find matching rows to update in the target table, another scan of the source table to find nonmatching rows to insert into the target table, and a third scan to find rows in the target table not contained in the source table that needed to be deleted.

With the MERGE statement, you can synchronize two tables by inserting, updating, or deleting rows in one table based on differences found in the other table, all in just a single statement, minimizing the number of times that rows in the source and target ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required