DROP PROCEDURE  IF EXISTS uspGetFeltoltottFajlokSzamaByOrarendiOraId 
GO

CREATE PROCEDURE uspGetFeltoltottFajlokSzamaByOrarendiOraId
   @pIntezmenyId INT
  ,@pTanevId INT
  ,@pOrarendiOraId INT
  ,@pFeloltesDatum DATETIME
AS
BEGIN
  SET NOCOUNT ON;

  SELECT COUNT(1)
  FROM T_DKT_FILE_OSSZES f
  INNER JOIN T_ORAFILE_OSSZES orf ON f.ID = orf.C_DKT_FILEID AND orf.TOROLT = 'F'
  WHERE (
      CONVERT(VARCHAR(10), f.C_FELTOLTESDATUM, 120) = CONVERT(VARCHAR(10), @pFeloltesDatum, 120)
      AND orf.C_ORARENDIORAID = @pOrarendiOraId
      )
    AND f.C_INTEZMENYID = @pIntezmenyId
    AND f.C_TANEVID = @pTanevId
    AND f.TOROLT = 'F'
END
GO


