Sqlserver存储过程中使用try-catch和事务
BEGIN TRY BEGIN TRANSACTION --逻辑代码 COMMIT TRANSACTION --提交事务 END TRY BEGIN CATCH SELECT @Msg = ERROR_MESSAGE() SET @iResult = 0 ROLLBACK TRANSACTION--回滚 END CATCH
BEGIN TRY BEGIN TRANSACTION --逻辑代码 COMMIT TRANSACTION --提交事务 END TRY BEGIN CATCH SELECT @Msg = ERROR_MESSAGE() SET @iResult = 0 ROLLBACK TRANSACTION--回滚 END CATCH