title: Output parameter value changes depending on error type
body: <p>I have a Stored procedure with an output parameter. In my procedure I have two lines with error and depending on which error is raised the value of the output parameter is different. Help me understand such kind of behavior of the output parameter.</p>
  
  <p>Here is the example:</p>
  
  <pre><code>CREATE PROC SP (@p1 int OUTPUT) AS
  BEGIN
   SET @p1 = @p1 + 10;
   select 5/0 
  END
  go
  
  
  
  DECLARE @v int;
  SET @v = 1;
  EXEC SP @v OUTPUT;
  PRINT @v;
  go
  --------------------------------
  </code></pre>
  
  <p>result is 11</p>
  
  <pre><code>CREATE PROC SP (@p1 int OUTPUT) AS
  BEGIN
   SET @p1 = @p1 + 10;
   SELECT * FROM nonExistentTable; 
  END
  go
  
  
  DECLARE @v int;
  SET @v = 1;
  EXEC SP @v OUTPUT;
  PRINT @v;
  go
  --------------------------------
  </code></pre>
  
  <p>result is 1</p>