Working on an application where transactions are created that log a range of numbers, i.e.

SysTranId, RangeFrom,RangeTo


So user enters a range in the system and I want to check whether any numbers in the users range, are contained within any of the ranges stored in the transactions.

i.e. Users Range 100010, 100022 (numbers 100010 through to 100022)

Have any of these numbers been used, regardless of the range (so 100015 could have been used in range 100000 to 1000015 and 100022 could have been used in range 100020 to 100025)

Is this something that can be done easily in SQL. I can do this by cycling through the table, which while there are a few hundred records won't be too bad, but this application will have hundreds of thousands of records.

Any ideas gratefully received

Colin