DROP PROCEDURE  IF EXISTS uspReferencesCount 
GO

CREATE PROCEDURE uspReferencesCount
     @pCsengetesiRendOraId INT
    ,@pTanevId INT
AS
BEGIN
  SET NOCOUNT ON;

  SELECT COUNT(1) AS darab
  FROM T_ORARENDIORA_OSSZES oo
  WHERE oo.C_CSENGETESIRENDORAID = @pCsengetesiRendOraId
    AND oo.TOROLT = 'F'
    AND oo.C_TANEVID = @pTanevId
  
  UNION
  
  SELECT COUNT(1) AS darab
  FROM T_TANITASIORA_OSSZES t
  WHERE t.C_CSENGETESIRENDORAID = @pCsengetesiRendOraId
    AND t.TOROLT = 'F'
    AND t.C_TANEVID = @pTanevId
END
GO


