title: SQL Server stored procedure display message after insert
body: <p>I'm pretty new to stored procedures.</p>
  
  <p>I'm using SQL Server.</p>
  
  <p>I'm trying to execute a stored procedure so that after the <code>INSERT</code> it returns a message 'Insert complete' or if it didn't insert 'Insert failed'</p>
  
  <p>I'm receiving an error </p>
  
  <blockquote>
    <p>Must declare the scalar variable "@oResult"</p>
  </blockquote>
  
  <p>I can't figure it out.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <pre><code>ALTER PROC master
      @iPatientFName varchar(20),
      @iPatientLName varchar(20),
      @iPatientAddr varchar(30),
      @iDOB date,
      @oResult VARCHAR(10) OUT    
  AS
  
  DECLARE @wardCount int
  SET @wardCount = (SELECT COUNT(ward_id) FROM dbo.patient_admissions_tbl)
  BEGIN
      SET NOCOUNT ON;
      if(@wardCount &lt; 5)
          BEGIN           
              INSERT INTO patient_tbl(patient_fname, patient_lname,     patient_address, patient_dob)
              VALUES(@iPatientFName, @iPatientLName, @iPatientAddr, @iDOB)                        
              SET @oResult = 'Patient inserted'
          END         
  END
  
  
  EXECUTE exam_master 'john', 'smith', 'new york', '10-10-1981', @oResult
  </code></pre>