准备:

  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

  

SQL Server save transaction的更多相关文章

  1. sql server 学习笔记 (nested transaction 嵌套事务)

    什么时候会用到嵌套事务 ? 为了代码复用,我们会写许多的储蓄过程,而中间如果需要使用到 transaction 难免就会发生嵌套了. sql server 并不直接支持嵌套事务. 但它可以用一些招式来 ...

  2. SQL Server does not purge row versioning records even the transaction are committed if there are other open transaction running in the databases with read-committed snapshot enabled .

    This is a by-design behavior. There is only one allocation unit in tempdb that istracking the versio ...

  3. Microsoft SQL Server Trace Flags

    Complete list of Microsoft SQL Server trace flags (585 trace flags) REMEMBER: Be extremely careful w ...

  4. Migrating Oracle on UNIX to SQL Server on Windows

    Appendices Published: April 27, 2005 On This Page Appendix A: SQL Server for Oracle Professionals Ap ...

  5. [转]How to nest transactions nicely - "begin transaction" vs "save transaction" and SQL Server

    本文转自:http://geekswithblogs.net/bbiales/archive/2012/03/15/how-to-nest-transactions-nicely---quotbegi ...

  6. [转]sql server transaction

    本文转自: http://www.2cto.com/database/201208/146734.html sql事务(Transaction)用法介绍及回滚实例   事务(Transaction)是 ...

  7. SQL Server 数据库的维护(三)__事务(transaction)和锁

    --维护数据库-- --事务(transaction)和锁-- --事务(transaction)-- --概述: 事务是指封装了一组T-SQL语句的单个逻辑单元.单元中的所有语句作为一个整体,在满足 ...

  8. SQL Server Transaction Log Truncate && Shrink

    目录 什么是事务日志 事务日志的组成 事务日志大小维护方法 Truncate Shrink 索引碎片 总结 什么是事务日志 Transaction log   是对数据库管理系统执行的一系列动作的记录 ...

  9. SQL Server中事务transaction如果没写在try catch中,就算中间语句报错还是会提交

    假如我们数据库中有两张表Person和Book Person表: CREATE TABLE [dbo].[Person]( ,) NOT NULL, ) NULL, ) NULL, [CreateTi ...

随机推荐

  1. ios消息的交互方式

    注意这些都是界面回传(即从第二个界面传到第一个界面,从第一个界面传到第二个界面的时候用第二个界面的属性即可)   iOS消息的交互方式有4种,分别为:通知,代理,block,kvo 现在我们对这个4中 ...

  2. C#1 输入输出 常量变量

    C#  输入输出  常量变量 //输出 Console.WriteLine("这是一行文字"); 自动回车的. Console.Write("Hello world&qu ...

  3. go learning notes

    1)  cgo $go install test.go # command-line-arguments /usr/bin/ld: unrecognized option '--build-id=no ...

  4. javase程序设计课后题答案

    ;第1章 Java概述 编译java application源程序文件将产生相应的字节码文件,这些字节码文件别的扩展名为.java 执行一个java程序fristapp的方法是运行java frist ...

  5. Android 动画小知识点

    <?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="h ...

  6. Get a handle on PHP Handlers

    PHP Handlers? mod_php? FPM? How do we make sense of the inner workings of PHP outside of our lines o ...

  7. yum 安装 5.6

    http://www.cnblogs.com/XBlack/p/5178758.html

  8. iOS多线程总结(二)NSOperation

    NSOperation.h定义了NSOperation,内容非常的简洁,NSOperation本身是一个抽象类,定义了一个要执行的Task,NSOperationQueue是一个Task队列,当Tas ...

  9. ACM学习-POJ-1004-Financial Management

    菜鸟学习ACM,纪录自己成长过程中的点滴. 学习的路上,与君共勉. ACM学习-POJ-1003-Financial Management Financial Management Time Limi ...

  10. #include <windows.h>

      1 FindWindowA 2 keybd_event 3 malloc 4 MessageBox 5 MessageBoxA 6 MessageBoxW 7 mouse_event 8 SetC ...