Sqlserver2005事务回滚案例

Sqlserver2005事务回滚案例,第1张

概述set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROCEDURE [dbo].[proc_UpdateDepartCode]  @oldCode varchar(50),     @newCode varchar(50),     @DepartID int,     @DepartName varchar(30),     @Depart

set ANSI_NulLS ON
set QUOTED_IDENTIFIER ON
go


ALTER PROCEDURE [dbo].[proc_UpdateDepartCode]
 @oldCode varchar(50),
    @newCode varchar(50),
    @DepartID int,
    @Departname varchar(30),
    @DepartAddress varchar(30),
    @PersonID int,
    @CompanyID int,
    @Result int output
AS
BEGIN
 -- SET NOCOUNT ON added to prevent extra result sets from
 -- interfering with SELECT statements.
    declare @sqlError int
    set @sqlError = 0
 SET NOCOUNT ON;
    Update tblDepart set ParentDepartCode = @newCode where ParentDepartCode = @oldCode
    set @sqlError = @sqlError + @@error
    Update tblDepart set DepartCode=replace(DepartCode,substring(DepartCode,1,4),ParentDepartCode) where ParentDepartCode = @newCode
    set @sqlError = @sqlError + @@error
    Update tblDepart set DepartCode = @newCode,Departname=@Departname,DepartAddress=@DepartAddress,PersonID=@PersonID,CompanyID=@CompanyID where DepartID = @DepartID
    set @sqlError = @sqlError + @@error
   
    if @sqlError <> 0
    begin
      rollback transaction
      select @Result = 0
    end
    else
    begin
       BEGIN TRANSACTION
       commit transaction
       select @Result = 1
    end

   

    END

总结

以上是内存溢出为你收集整理的Sqlserver2005事务回滚案例全部内容,希望文章能够帮你解决Sqlserver2005事务回滚案例所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1181483.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存