How to do bulk update in SQL server in single update statement

  • Hi,
    I have almost 1M records in which I need to update its Company name against each ID.
    How I can update it in single update statement in sql server.
    In short I would like to perform 

    update tblname set 
    Name='updatedname'(which would be 100s of)
    where 
    cid in 
    (
    100s of

    Thanks,
    Nilesh

  • You should load a staging table with the new (id,name) pairs and then updat the target table from the staging table.
    Something like this:
    UPDATE targ
    SET name = src.name
    FROM SomeTable AS targ
    INNER JOIN StagingTable AS src
     ON targ.id = src.id

    -- Gianluca Sartori

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

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