title: Why return -1 is not working as expected
body: <p>I am new to SQL Server. Please help me with this issue </p>
  
  <pre><code>RAISERROR('There is a problem in the code',16,1)
  RETURN -1 
  </code></pre>
  
  <p>This is working perfectly fine. So I put this in a common procedure like this:</p>
  
  <pre><code>CREATE procedure  [dbo].[Raise_Error]
      (@ErrorMsg varchar(6000) ,
       @ErrorSeverity integer = 16,
       @ErrorState integer = 1)
  AS
  BEGIN           
      RAISERROR (@ErrorMsg, @ErrorSeverity, @ErrorState)
      RETURN -1 
  END  
  </code></pre>
  
  <p>Now when I call this procedure from another procedure     </p>
  
  <pre><code>CREATE PROCEDURE TEST_ORIG
  AS
  BEGIN   
      IF NOT EXISTS (SELECT * FROM  table where FISCALYEAR='2016')
      BEGIN
          EXEC utils.dbo.[Raise_error]
               @ErrorMsg = 'There are no valid records for     processing'                             
          RETURN -1 
      END
  </code></pre>
  
  <p>I am getting an error message </p>
  
  <blockquote>
    <p>Msg 178, Level 15, State 1, Line 13<br>
    A RETURN statement with a return value cannot be used in this context</p>
  </blockquote>
  
  <p>Can anyone throw some light on what is happening here and how can I correct it? I need to return -1 here.</p>
  
  <p>Thanks in advance </p>