Insert-Delete A Row

  • Dear,

    I want to insert a row from Table1 to Table2 after that I want to delete that row from Table1.

    But I wanna ensure that if the insert command is being executed successfully then delete command will execute. If the insert command is not being executed successfully then delete command will not execute too.

    Please help me to solve the logic.

  • begin transaction

    begin try

    insert ...

    delete ...

    commit transaction

    end try

    begin catch

    rollback transaction

    end catch

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thank you, Gila Monster.

    That works

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

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