Commit update

  • How can I do commit in my update? I am updating table with a lot of records before it fails on me, I want to make sure at least updates some of the records. How can I do it?

    Here is an update:

    Update table1

    SET ext_table1.Qty = table2.Qty

    from view1

    view

    select top 1000000 from

    INNER JOIN

    table2 ON table1.KU = table3.KU

  • Break your Update into smaller slices by including some kind of condition that you are aware (may be by using a Date Column and putting between Clause)

    And also use

    BEGIN TRANS TRANSACTIONNAME

    and

    COMMIT TRANS TRANSACTIONNAME


    Bru Medishetty

    Blog -- LearnSQLWithBru

    Join on Facebook Page Facebook.comLearnSQLWithBru

    Twitter -- BruMedishetty

  • You mean

    Begin

    Begin transaction

    Update statment

    Commit

    End

    How can I right code that I want every 100 records to commit?

  • Krasavita (10/22/2009)


    How can I right code that I want every 100 records to commit?

    Try this

    set rowcount 100

    begin tran

    update MYTABLE

    set COL1 = 'COL1'

    where COL1 = 'COL2'

    after found no error then commit the above tran or otherwise rollback tran

  • Thank you,but I wanted to commit 100 and then again 100. How can I write it.Thank you

Viewing 5 posts - 1 through 4 (of 4 total)

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