title: T-SQL - Bit Output Parameter Default Value
body: <p>I'm currently investigating a bug in a stored procedure build over MS SQL Server 2008.
  Current stored procedure signature looks like: </p>
  
  <pre><code>CREATE PROCEDURE dbo.&lt;Name&gt;
  (
      ParameterOne int
      , ParameterTwo bit output
  )
  </code></pre>
  
  <p>In the code the output parameter value is being evaluated to determine code flows which is at least suspicious to me. Code looks like this: </p>
  
  <pre><code>IF ( ParameterTwo = 0 )
  BEGIN
        PRINT ParameterTwo
        -- Do stuffs
  END
  
  IF ( ParameterTwo = 0)
  BEGIN
        PRINT ParameterTwo
        -- Do other stuffs
  END
  </code></pre>
  
  <p>On debugging (using PRINTs) I configured flags to be displayed inside the block #1 and block #
  2
   but none of them were shown when executed the code. 
  However, if you assign a value to ParameterTwo ( ParameterTwo = 0 ) right before the block #1 is executed, the flags are being displayed as expected.</p>
  
  <p>My concern is obviously about bit output parameter creation. When you create a bit parameter (in/out) which is the default value being assigned by MS SQL Server(if any)?. Is that a NULL value? I was under the impression it was a 0 (false) but it does not seems so.</p>
  
  <p>Btw - I'm considering to avoid the output parameter usage withing the code for comparison purposes. Instead, I would tend to think there would be more clear to use internal variable and assign its value to the output parameter before stored procedure ends.</p>
  
  <p>Any responses/comments will be appreciated. </p>
  
  <p>Thanks in advance.</p>