title: SQL Server not returning correct output from a user defined function
body: <p>I am trying to call a UDF from another UDF and hoping to get desired output. However, SQL Server is not returning anything in the second UDF. </p>
  
  <p>My calls are:</p>
  
  <pre><code>DECLARE @V_F VARCHAR(200)
  EXEC @V_F = dbo.fnCalcDiscount 220,'1234567812345679','Thailand'
  PRINT @V_F
  GO
  
  DECLARE @V_F VARCHAR(200)
  EXEC @V_F = dbo.groupsanddiscounts '1234567812345679','Thailand',220,220
  PRINT @V_F
  GO
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>110
  0
  </code></pre>
  
  <p>Body of <code>groupsanddiscounts</code>:</p>
  
  <pre><code>CREATE FUNCTION [dbo].[groupsanddiscounts]
      (@p_PROMOCODE VARCHAR(50),
       @p_COUNTRY VARCHAR(100),
       @p_TOTVAL INT,
       @p_NEWSIMCOST INT) 
  RETURNS VARCHAR(300) 
  AS BEGIN
      DECLARE @p_FINALVALUE VARCHAR(300)
  
      SELECT @p_FINALVALUE =  dbo.fnCalcDiscount (@p_NEWSIMCOST, @p_PROMOCODE, @p_COUNTRY)
      RETURN @p_FINALVALUE         
  END
  </code></pre>
  
  <p>Body of <code>fnCalcDiscount</code></p>
  
  <pre><code>CREATE FUNCTION [dbo].[fnCalcDiscount] 
      (@p_TOTVAL INT, 
       @p_PROMOCODE VARCHAR(200), 
       @p_COUNTRY VARCHAR(200))
  RETURNS VARCHAR(300)
  AS BEGIN
      DECLARE @retResult VARCHAR(300) 
  
      SELECT @retResult = '110'
      RETURN @retResult
  END
  </code></pre>
  
  <p>Any idea what is going berserk? </p>
  
  <p>Thanks</p>
  
  <p><a href="https://i.stack.imgur.com/A0qm4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A0qm4.png" alt="Output"></a></p>