存储过程事务回滚及try catch

begin
	begin try--捕捉异常
		begin tran--可以理解成新建一个还原点。
		********各种新增修改操作
		commit tran--提交事务
	end try
	begin catch--出现异常
		select error_number() as error_number ,
		error_message() as error_message,
		ERROR_LINE()--设置返回异常信息
		rollback tran--回滚事务
	end catch
end

猜你喜欢

转载自blog.csdn.net/q1923408717/article/details/115002167