title: What is use of varchar output parameter in stored procedure - cannot 'return @myvarchar' but can 'select @myvarchar'
body: <p>xample:</p>
  
  <pre><code>CREATE PROCEDURE dbo.sp_Delete (@p1 INT, @p2 VARCHAR(10) OUTPUT)
  AS
      --@p1 will have calculations done and get a value for @p2
      SET @p2 = 'test'
      RETURN @p2
  </code></pre>
  
  <p>Test:</p>
  
  <pre><code>DECLARE @p2 VARCHAR(100)
  EXEC sp_Delete
       @p1 = N'1',
       @p2 = N''
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Conversion failed when converting the varchar value 'test' to data type int.
  </code></pre>
  
  <p>BUT
  you can do this:</p>
  
  <pre><code>ALTER PROCEDURE dbo.sp_Delete (@p1 INT)
  AS
      --@p1 will have calculations done and get a value for @p2
      SELECT 'test'
  
  
      EXEC sp_Delete
           @p1 = N'1'
  </code></pre>
  
  <p>So my question is, what is the use of having a OUTPUT parameter of type varchar (note I'm not questioning an output parameter of type int), when you can't use "return @myvar" if it is a varchar. You can just "select @myvar".
  I am trying to figure out what I am doing wrong, because I think I don't understand the use of a specific varchar output variable.</p>