准备:

  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. Python urllib和urllib2模块学习(一)

    (参考资料:现代魔法学院 http://www.nowamagic.net/academy/detail/1302803) Python标准库中有许多实用的工具类,但是在具体使用时,标准库文档上对使用 ...

  2. 处理json中的异常字符

    在很多场景中需要通过json传递数据,如果json中包含英文的",""'"之类的字符,会导致json解析失败 可以用一些在线的json格式检查网站检查是否含有异 ...

  3. linux配置jdk环境详解

    环境:Redhat Server 5.1(虚拟机) 工具:Xftp4  jdk-7-linux-i586.rpm文件 步骤1:把jdk-7-linux-i586.rpm文件拷贝到/usr/local目 ...

  4. PHP5中__call、__get、__set、__clone、__sleep、__wakeup的用法

    __construct(),__destruct(),__call(),__callStatic(),__get(),__set(),__isset(),__unset(),__sleep(),__w ...

  5. 用Python写的一个多线程机器人聊天程序

    本人是从事php开发的, 近来想通过php实现即时通讯(兼容windows).后来发现实现起来特别麻烦, 就想到python.听说这家伙在什么地方都能发挥作用.所以想用python来做通讯模块...所 ...

  6. express4.0之后不会解析req.files,必须加一个插件multer

    express 4 + 用multer express4.0之后不会解析req.files,必须加一个插件multer http://www.w3school.com.cn/tags/att_form ...

  7. Swfit中视图跳转

    .跳转到任一UIViewController var sb = UIStoryboard(name: "Main", bundle:nil) var vc = sb.instant ...

  8. Girl_iOS100天学iOS的第一天(规划)

    不好的开端. 只是还好,总算是開始. 今天一直在做项目中的某个模块,发现自己尽管工作了一段时间,但编码速度还是够慢的 >.< 探究其为什么慢的原因,还是由于自己对某些控件等基础的不熟悉,如 ...

  9. ping操作

    如何使用Ping命令 使用Ping命令检查网络故障方法 发布时间:2012-09-13 17:42 作者:电脑百事网原创 来源:www.pc841.com 53165次阅读   电脑百事网手机版:3g ...

  10. ASP.NET设置焦点到输入框

    Page.SetFocus(txtLoginName);