title: Stored Procedures: Addition of two numbers by passing them as parameters
body: <p>I am currently learning stored procedures, and have been trying to do the simple exercise of adding two numbers by passing them to my sp. 
  The problem I'm facing is with data type conversions and loss of data.
  I'm defining my procedure as follows:</p>
  
  <pre><code>create proc addn(@a float, @b float)
  as
  begin
  declare @sum varchar
  set @sum=cast((@a+@b) as varchar)
  print 'the sum of '+cast(@a as varchar)+' and '+cast(@b as varchar)+' is ' cast((@a+@b) as varchar)
  print @sum
  end
  </code></pre>
  
  <p>The procedure is being called as follows:</p>
  
  <pre><code>declare @a1 float, @b1 float
  set @a1=41
  set @b1=6.2
  exec addn @a1,@b1
  </code></pre>
  
  <p>The result I'm getting is:</p>
  
  <pre><code>the sum of 41 and 6.2 is 47.2
  4
  </code></pre>
  
  <p>Now I can't understand why I'm getting only a 4 in @sum. It is storing only the first digit of the result of any addition that is performed. Please help!</p>