title: Scalar function calculation
body: <p>I am trying to sum the contents of two variables in a scalar function and I want to use the outcome of this calculation in a string. However, the script does not return the value 10 in the table. What am I doing wrong?</p>
  
  <pre><code>Alter FUNCTION [dbo].[_KOptionsPounds] ()
  RETURNS nvarchar(max)
  AS
  BEGIN
       Declare @test int=5
       Declare @test2 int=5
       Declare @output nvarchar(max)
       Declare @testcalc int
  
       select @testcalc = @test + @test2
  
       set @output='&lt;table&gt;&lt;tr&gt;&lt;td&gt;£'+@testcalc+'&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;'
  
  RETURN @output
  END
  </code></pre>