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事务回滚案例所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)