例如,我有2个存储过程
CREATE PROCEDURE [dbo].[sProcedure1]
AS
BEGIN TRY
BEGIN TRANSACTION
EXEC sProcedure2
SELECT * INTO Table3 FROM Table2
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH
CREATE PROCEDURE [dbo].[sProcedure2]
AS
BEGIN TRY
BEGIN TRANSACTION
SELECT * INTO Table2 FROM Table1
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH
如果sProcedure2成功执行但sProcedure1在SELECT * INTO Table3 FROM Table2上会出错怎么办?
Table2会填充数据还是从sProcedure1回滚将填充到sProcedure2?
谢谢
答案 0 :(得分:0)
根据我的说法,如果Stored Proc 1失败,所有内容都应该回滚,你不会在表2和表2中插入任何数据。表3。