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

Hello,
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.
andrishelpAsked:
Who is Participating?
 
Ephraim WangoyaCommented:
try
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

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.