The MERGE statement

Let's show the MERGE statement in the following example. We will still use the Landing.Products table populated in the previous section. We also will create a new Staging schema and insert the schema into a new table, named Staging.Products.

If the table is empty as a result of the experiments truncating it, just populate it once again.

Let's start to create the staging table. This will be better normalized and it will also include one new column called Discontinued. The following code shows its creation:

USE DemoCustgoCREATE SCHEMA Staging AUTHORIZATION dbogoCREATE TABLE Staging.Products(Id int not null IDENTITY, ProductKey int not null, ProductName nvarchar(50) not null, ListPrice dec(8, 2) not null, Discontinued bit ...

Get Hands-On Data Science with SQL Server 2017 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.