SQL table update

Hema Ramachandran 176 Reputation points
2021-11-12T09:49:16.22+00:00

I have two tables:

148805-image.png

I want to update Table1 with Table2 data based on ID

SQL Server | Other
0 comments No comments
{count} votes

Answer accepted by question author
  1. Hema Ramachandran 176 Reputation points
    2021-11-12T10:59:14.867+00:00

    I found the answer.

    UPDATE T1
    SET Name= T2.Name
    FROM Table1 AS T1
    INNER JOIN
    Table2 AS T
    ON T1.ID = T2.ID and T1.Name<> T2.Name

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Olaf Helper 47,581 Reputation points
    2021-11-12T09:57:32.01+00:00

    Then do it; where is the problem?

    UPDATE T1
    SET Column = T2.OtherColumn
    FROM Table1 AS T1
         INNER JOIN
         Table2 AS T
        ON T1.ID = T2.ID
    

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.