Published on: 26 Feb, 2021

How to update table with join another table in TSQL?

Tumblr Digg Google Plus

In this article, we going to learn how to update a table with join another table in SQL Server. Let says we have two products table as below.

We are going to update the Product table based on the data we have from the Main Product Table. Both tables are joined by Id.

Here is the full TSQL Query to update a table with join another table in SQL Server.


UPDATE P
SET P.Name = MP.Name,
	P.Price = MP.Price,
	P.SKU = MP.SKU
FROM Products P
INNER JOIN MainProducts MP
ON P.Id = MP.Id

Comments

There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.