存储过程中异常捕捉机制及事物回滚
详细用法可以参照:http://blog.csdn.net/kk185800961/article/details/48347873
具体用法:
BEGIN TRAN BEGIN TRY ...//具体代码段 COMMIT TRAN END TRY BEGIN CATCH DECLARE @ErrorMessage NVARCHAR(4000) , @ErrorSeverity INT , @ErrorState INT; SET @ErrorMessage = ERROR_MESSAGE(); SET @ErrorSeverity = ERROR_SEVERITY(); SET @ErrorState = ERROR_STATE(); RAISERROR (@ErrorMessage, @ErrorSeverity,@ErrorState ); ROLLBACK TRAN END CATCH