CREATE FUNCTION [dbo].[GetDefaultOrderBookSegment] ()  
RETURNS int AS  
BEGIN 
  DECLARE @Res int

  SELECT @Res = Convert(int, IsNull(KeyValue, '0')) FROM HotelSetup WITH (NOLOCK) WHERE SearchKey = 'DefaultOrderBookSegment'
  IF  (@Res = 0)
  SELECT @Res = Number FROM Segments WITH (NOLOCK) Where ((MarkAsDeleted='0') OR (MarkAsDeleted is null))

  RETURN @Res
END

