Update null column

  • Dear all,

    i have the two table like

    table1

    Batchid batchname

    ———- ————–

    1 b1

    2 b2

    3 b3

    table2

    indexid Batchid document

    ——— ———- ————-

    1 null b1

    2 null b1

    3 null b2

    4 null b3

    5 null b3

    6 null b2

    **************************

    Result i want:—-

    indexid Batchid document

    ——— ——— ———-

    1 1 b1

    2 1 b1

    3 2 b2

    4 3 b3

    5 3 b3

    6 2 b2

    here document get the value from batchname(table1)

    so it have one or more batchname as under document(table2)

    i want to update batchid according to first table.

    how can i do this?

  • You can do this by a simple join

    UPDATET2

    SETBatchid = T1.Batchid

    FROMtable2 T2

    INNER JOIN table1 T1

    ON T2.document = T1.batchname


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

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

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