Update table value

  • Hi,

    i have a table with following structure

    TableA

    OldId int,

    NewId int

    select * from tableA;

    OldID NewID

    22

    23

    24

    I have another table that holds OldId.

    select oldId from TableB;

    OldId

    10

    11

    12

    now I want to update tableA from TableB, in way that first value of TableB update against first value in TableA.OldId

    I am expecting result after that update like following

    select * from tableA;

    OldID NewID

    10 22

    11 23

    12 24

    Is this update can happen without any other criteria ? or how can I do so ?

  • Add a Row_Number() column to both (with sorting as you require) and join on that - then the update becomes trivial.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • thanks bro it worked.

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

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