Update table based on condition

  • mathewspsimon

    SSCommitted

    Points: 1706

    I have 2 tables A- columns id & Amount.

    Table A

    Id Amount

    1 10

    2 20

    3 30

    Another table B columns id,Total_Amount,Product

    Table B

    Id Total_Amount Product

    1 Apple

    3 Mango

    5 Orange

    Now I want to update B with the Amount in A where A.id=B.Id

    can u give me a script for this in MS SQL server 2000.I am a newbie.

  • francisco-558009

    SSC Enthusiast

    Points: 139

    Hi!

    UPDATE B SET B.Total_Amount=A.Amount

    FROM A AS A INNER JOIN B AS B ON

    A.Id=B.Id

  • mathewspsimon

    SSCommitted

    Points: 1706

    Hi thanks.it worked.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply