Executing a stored procedure inside BEGIN/END TRAN

2019-01-22 02:00发布

If I create a Stored Procedure in SQL and call it (EXEC spStoredProcedure) within the BEGIN/END TRANSACTION, does this other stored procedure also fall into the transaction?

I didn't know if it worked like try/catches in C#.

7条回答
倾城 Initia
2楼-- · 2019-01-22 02:27

I believe in MS SQL Server the stored procedure execution would happen within the transaction, but be very careful with this. If you have nested transactions (ie, transaction outside of the stored procedure and a different transaction inside the stored procedure), a rollback will affect ALL of the transactions, not just the nearest enclosing transaction.

查看更多
登录 后发表回答