• 在Sql Server 查询分析器里使用事务


    declare @updatecount int
    begin TRAN

    DECLARE @tbid INT
    SELECT @tbid=iMax FROM tbID WHERE strName='ipcclid'

    INSERT into pccl(ipcid,cph,crkdbh,drq,iywdwid,cywdwbh,cywdwmc,iclbh,cclbh,cclmc,
    cgg,cdw,nwjsl,nwjdj,nwjje,cRemark,cPeriod,cBillCode_Buy,cBuyUnit,nBuyAmount,
    nAmount_In,nBuyUnitRate,FBuyUnitRate,cBuyRate,nBuyPrice,nTaxBuyPrice,nBuyTickAmount,nTaxFBuyPrice,ID_Money,cForeignName,
    nForeignRate,nTaxRate,nTaxPrice,iMaterialState)
    VALUES(@tbid,'','RK000398',CONVERT(DATETIME,'2015-12-24',120),36,'G0025','泉州经济技术开发区新安消防器材经营部',1691,'10030050','安全出品灯(正)',
    '3W','个',3,38,114,'移动端[CG000521]','2015年12月','CG000521','个',3,
    3,1,'1/1',1,38,38,3,38,1,'本位币',
    1,0,38,0)

    SET @tbid += 1

    INSERT into pccl(ipcid,cph,crkdbh,drq,iywdwid,cywdwbh,cywdwmc,iclbh,cclbh,cclmc,
    cgg,cdw,nwjsl,nwjdj,nwjje,cRemark,cPeriod,cBillCode_Buy,cBuyUnit,nBuyAmount,
    nAmount_In,nBuyUnitRate,FBuyUnitRate,cBuyRate,nBuyPrice,nTaxBuyPrice,nBuyTickAmount,nTaxFBuyPrice,ID_Money,cForeignName,
    nForeignRate,nTaxRate,nTaxPrice,iMaterialState)
    VALUES(@tbid,'','RK000399',CONVERT(DATETIME,'2015-12-24',120),36,'G0025','泉州经济技术开发区新安消防器材经营部',1692,'10030051','安全出口灯(左)',
    '3W','个',4,38,152,'移动端[CG000521]','2015年12月','CG000521','个',3,
    4,1,'1/1',1,38,38,4,38,1,'本位币',
    1,0,38,0)

    SET @tbid += 1

    UPDATE tbID SET iMax=@tbid WHERE strName='ipcclid'

    set @updatecount = @@rowcount

    if(@updatecount = 1)
    begin
    commit tran
    print 'chenggomg'
    end
    else
    begin
    rollback tran
    print 'shibai'
    end

  • 相关阅读:
    Linux 命令汇总总结相关
    数据结构---python---表
    python-----Queue模块
    再看python多线程------threading模块
    <转> Struct 和 Union区别 以及 对内存对齐方式的说明
    python装饰器
    HTTP权威指南----缓存
    HTTP权威指南----连接管理
    以python理解Linux的IO多路复用,select、poll、epoll
    <转载> pycharm快捷键及一些常用设置
  • 原文地址:https://www.cnblogs.com/zhangzhifeng/p/5106309.html
Copyright © 2020-2023  润新知