sql server - T-SQL function for determining if two integer ranges overlap -
i have 2 integer ranges , need determine if overlap. 1 or both ranges open-ended. have t-sql function serves purpose?
shorter, hackier solution (set nulls min/max values):
set @p_start_range1 = isnull(@p_start_range1, -2147483648); set @p_end_range1 = isnull(@p_end_range1, 2147483647); set @p_start_range2 = isnull(@p_start_range2, -2147483648); set @p_end_range2 = isnull(@p_end_range2, 2147483647); select @result = case when @p_start_range1 > @p_end_range2 or @p_start_range2 > @p_end_range1 0 else 1 end;
Comments
Post a Comment