SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[DoesReservationGroupMatchParentRoom](@AreservationGroup INT, @AParentRoomNumber INT, @ARoomNumber INT, @AArrival DATETIME, @ADeparture DATETIME) 
RETURNS BIT
AS
BEGIN
	DECLARE @ResultVar BIT
	DECLARE @RoomReservationGroup INT

	SET @ResultVar = 0
	SELECT @RoomReservationGroup = dbo.GetReservationGroupForParentRoom(@AParentRoomNumber,@ARoomNumber, @AArrival, @ADeparture)

	IF (@RoomReservationGroup = @AreservationGroup) OR (@RoomReservationGroup = -1)
		Set @ResultVar = 1

	RETURN @ResultVar

END
GO

