title: Stored Procedure, find the duplicate file name and return the value
body: <p>I have logic to verify whether the filename is unique or not. For this I need to pass the parameter 'FileName' </p>
  
  <p>Logic: </p>
  
  <pre><code>SELECT value = COUNT(*)  
  FROM  ProcessingLog
  WHERE ProcessingOutcome IN (1,2)  
  AND FileName = [FileName] 
  
  IF value &lt;&gt; 0 THEN  
  RETURN ErrorID 2 
  </code></pre>
  
  <p>Default: n/a <br>
  Error Code: 2: E002: Source File has been previously processed (duplicate Source File)  <br>
  Output Target: ProcessingLog.ErrorID  <br>
  Output Format: int </p>
  
  <p>I wrote a query like this:</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[xx]    
      @FileName int = NULL OUTPUT    
  AS
  BEGIN       
      DECLARE @V_FileName VARCHAR(225);
  
      SET NOCOUNT ON;
  
      SELECT FileName, count(*)
      FROM  PbrcServiceProcessingLog  
      WHERE ProcessingOutcome IN (1,2)  
            AND SourceFileName = @SourceFileName 
      GROUP BY SourceFileName
      HAVING COUNT(*) &gt; 0
  
      IF count !=0 THEN  RETURN ErrorID 2     
  END
  </code></pre>
  
  <p>How can I pass the errorID into the processing ?</p>