What you could do is create a table-valued function that returns a range of numbers. Here's an example (I have been lazy and used a simple loop to create the numbers, you could do it much more efficiently, but I wanted to just show you the basic idea)create function NumberBlock(@start int, @end int)returns @NumberBlockTable table (Number int)asbegin while @start <= @end begin insert @NumberBlockTable values (@start) set @start = @start + 1 end returnendselect * from NumberBlock(1000, 1999)
So then you could join that with your other table, something likeselect * from Usedinner join NumberBlock(1000, 1999) as N on Used.UsedNumber = N.Number