How to commit and rollback transaction in sql server?

前端 未结 3 780
自闭症患者
自闭症患者 2020-12-05 05:50

I have a huge script for creating tables and porting data from one server. So this sceipt basically has -

  1. Create statements for tables.
  2. Insert for po
3条回答
  •  隐瞒了意图╮
    2020-12-05 06:21

    Avoid direct references to '@@ERROR'. It's a flighty little thing that can be lost.

    Declare @ErrorCode int;
    ... perform stuff ...
    Set @ErrorCode = @@ERROR;
    ... other stuff ...
    if @ErrorCode ...... 
    

提交回复
热议问题