Sno From To Allotedto 1 1 150 A 2 151 249 B 3 250 500 C 4 450 459 D
declare @from int declare @to int set @from= 450 set @to= 459 if exists(select * from tableName where ([From]<=@from and [To] >=@from) or ([From]<=@to and [To] >=@to)) print 'Invalid Range' else print 'Valid Range'
IF EXISTS( SELECT 1 FROM tbl_Range t WHERE @To BETWEEN t.[From] AND t.[To] AND @From BETWEEN t.[From] AND t.[To]) BEGIN print 'duplicate'; END ELSE BEGIN print 'Not duplicate'; END
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)