Updating joined tables in sql server

Rated 4.45/5 based on 584 customer reviews

For example, the Source Table is New Product and destination is Productmaster and the primary key is Product ID, then merge condition should be as following: This clause will be used when we want to update or delete the records on the destination table.Here records are considered as matching when data within the joined columns are the same.Using the MERGE statement, we can change data in a target table based on data in a source table.Using it, we can execute INSERT, UPDATE and DELETE on the target tables within a single query block.At the same time, we will have a full control on the performed operation, which will be faster and easier to maintain.

Mst Product(ID, Product_ID, Product_Name) VALUES (33, 'MED146', 'Losapuritriol') INSERT dbo.Mst Product(ID, Product_ID, Product_Name) VALUES (38, 'MED152', 'Ecopurimuc') INSERT dbo.Mst Product(ID, Product_ID, Product_Name) VALUES (39, 'MED153', 'Aerocarpambid') INSERT dbo.Mst Product(ID, Product_ID, Product_Name) VALUES (36, 'MED149', 'Durachloridevant') INSERT dbo.Mst Product(ID, Product_ID, Product_Name) VALUES (37, 'MED151', 'Renachloridenide') INSERT dbo.

Leave a Reply