title: SQL Server decimal variable assignment?
body: <p>I'm trying to write a stored procedure and I'm getting unexpected divide by 0 exceptions.  </p>
  
  <p>I've narrowed it down to the following example.  </p>
  
  <p>Why in the world does this :</p>
  
  <pre><code>    declare @A decimal;
      declare @B decimal;
      declare @C decimal;
  
      set @A = 4;
      set @B = 9;
      set @C = @A/@B 
  
      select @A/@B as 'Expected'
      select @C as 'Wut'
  </code></pre>
  
  <p>result in this? </p>
  
  <pre><code>    Expected
      ---------------------------------------
      0.4444444444444444444
  
      (1 row(s) affected)
  
      Wut
      ---------------------------------------
      0
  
      (1 row(s) affected)
  </code></pre>