CREATE FUNCTION dbo.AvailableRooms (@RoomTypeNumber INT, @StartDate DATETIME, @EndDate DATETIME) 
RETURNS @Result TABLE (RoomNumber INT, Number INT, Description VARCHAR(50), ParentRoomNumber INT) AS 
BEGIN 
    INSERT INTO @Result (RoomNumber, Number, Description, ParentRoomNumber)
    SELECT RoomNumber, Number, Description, ParentRoomNumber from Rooms (NOLOCK)
	WHERE roomtypenumber = @RoomTypeNumber
	AND dbo.GetRoomStatus(roomnumber, 0, @StartDate, @EndDate) = 0
    RETURN
END