title: How could I force the data type of a computed column to a bit field that don't allow nulls?
body: <p>I got a computed column that I need to be a bit field, here an example of formula :</p>
  
  <pre><code>case when ([some_field] &lt; [Some_Other_field]) 
  then 0 
  else 1 
  end
  </code></pre>
  
  <p>The data type of computed column set using this formula is <code>int</code>.</p>
  
  <p>What's the best way to force the correct data type?</p>
  
  <p>With a <code>CONVERT</code> statement on the whole case, data type is <code>bit</code> but it <code>Allow Nulls</code> </p>
  
  <pre><code>CONVERT([bit], 
          case when (([some_field] &lt; [Some_Other_field]) 
          then 0 
          else 1 
          end,
          0)
  </code></pre>
  
  <p>Same thing with a <code>CONVERT</code> statement on the result expressions, data type is <code>bit</code> but it <code>Allow Nulls</code>  </p>
  
  <pre><code>case when (([some_field] &lt; [Some_Other_field]) 
  then CONVERT([bit], (0), 0) 
  else CONVERT([bit], (1), 0) 
  end
  </code></pre>
  
  <p>Or there is a smarter way of doing this?</p>