如何使一个交易覆盖多个存储过程?

Ric*_*lda 4 sql-server stored-procedures transactions sql-server-2008

我需要在单个数据库的单个事务中包含多个存储过程,如果任何存储过程失败,则回滚范围内处理的所有存储过程的事务。

我使用 SQL-SERVER 2008

Ray*_*Ray 5

begin transaction
begin try
  exec proc_1
  exec proc_2
  exec proc_3
  commit transaction
end try
begin catch
  rollback transaction
end catch
Run Code Online (Sandbox Code Playgroud)