您的位置:首页 > 博客中心 > 数据库 >

SQL Server save transaction

时间:2022-03-14 01:31

准备:

  create table Nums(X int);

  目的:只向表中插入一行。

-------------------------------------------------------------------------------------------------------------------------------------

  begin transaction tran_A -- 最好是为事务定义一个名字。

    insert into Nums(X) values(9);

    save transaction save_tran; --定义一个事务的保存点、当要回滚事务时,可以回滚到这里。

    insert into Nums(X) values(4),(3),(2),(1);

    rollback transaction save_tran;--回滚事务到保存点

  commit transaction tran_A;-- 提交事务。
  go

  gxlsystem.com,布布扣

 

热门排行

今日推荐

热门手游