• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

Updating Multiple columns of a Table by selecting Multiple columns from another Table

I have a table T1 which has the following columns A, B, C and D.
I have another table T2 having these columns: P, Q, R and S.

Now I want to update the table T1, like this:
I will select the columns from the table T2, and update the columns of T1.

I mean, Column A of T1 should be updated by (Select P from T2),

Column B of T1 should be updated by (Select Q from T2)..

And so on..
Can anyone please help me, in finding the solution for the same?
Thanks in advance.
1 Solution
Ephraim WangoyaCommented:
update T1
set A = T2.P,
    B = T2.Q,
    C = T2.R,
    D = T2.S
from T2 
inner join T1 on T2.PrimaryKey = T1.PrimaryKey

Open in new window


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now