DROP PROCEDURE IF EXISTS [dbo].[sp_GetHelyettesitoTanarTanorahoz]
GO
-- =============================================
-- Author:    <Zsiga Attila>
-- Create date: <2016.03.09.>
-- Description:  <Tanorahoz tartozo helyettesito tanar>
-- =============================================
Create PROCEDURE [dbo].[sp_GetHelyettesitoTanarTanorahoz]
  @pOrarendiOraID int,
  @pDatum DateTime
AS
BEGIN
  SET NOCOUNT ON;
  
  SELECT
    tto.C_HELYETTESITOTANARID HelyettesitoID
  FROM T_ORARENDIORA oo
  JOIN T_TANITASIORA tto ON tto.C_ORARENDIORAGROUPID = oo.C_ORARENDIORAGROUPID AND tto.C_DATUM BETWEEN oo.C_ORAERVENYESSEGKEZDETE AND oo.C_ORAERVENYESSEGVEGE 
  WHERE
    oo.ID = @pOrarendiOraID
    AND tto.C_DATUM = @pDatum

END
GO
