This may not be possible, but I thought I'd throw it out here:
Given the following table:
ID, Begin, End
123, 1, N
Where N is an integer, write a query to return the following result set:
ID, Begin, End
123, 1, 1
123, 1, 2
123, 1, 3
.
.
.
123, 1, N
The platform we are using is SQL Server 2005, but if you can do it with another flavor of SQL, I'd still be interested in the solution.
This will work up to 99,999, and you can easily modify it to add more numbers. It needs no pre-existing numbers table and no stored procedure, and is still incredibly fast. Works on at least SQL Server 2000 and up, and is easily ported to other flavours of SQL:
Given some (theoretically infinite, but you could pre-populate) table Integers, containing all the integers, the answer is reasonably simple:
With a clustered index on Integers.I, this should be pretty fast. You could pre-populate integers in a stored-proc (based on the result from
SELECT max(End) FROM YourTable
).try this:
comments
and use this query instead:
have to have a table Numbers before this will work (see link above)
it will run better.