SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

IF OBJECT_ID('[dbo].[sp_GetNemKotottMunkaIdoIdByDelete]') IS NOT NULL 
BEGIN
  DROP PROCEDURE [dbo].[sp_GetNemKotottMunkaIdoIdByDelete] 
END  
GO

CREATE PROCEDURE [sp_GetNemKotottMunkaIdoIdByDelete]
	@IntezmenyId int
	,@TanevId int
	,@IdoszakKezdete datetime
	,@IdoszakVege datetime
	,@GroupId nvarchar(36)
AS
BEGIN
	SET NOCOUNT ON;

	SELECT
		nkm.ID
	FROM T_NEMKOTOTTMUNKAIDO_OSSZES nkm
	WHERE
		C_GROUPID = @GroupId AND C_INTEZMENYID = @IntezmenyId AND C_TANEVID = @TanevId AND TOROLT = 'F'
		AND nkm.C_KEZDETE BETWEEN @IdoszakKezdete AND @IdoszakVege

END