Return a table of numbers from 0 up to a some value. I'm facing this recurring task once in several years. Such periodicity induces me to invent solution once again but using contemporary features.
This time I have succeeded to solve the task in one select:
declare @count int;
set @count = 1000;
with numbers(value) as
select value * 2 + 1 from numbers where value < @count / 2
select value * 2 + 2 from numbers where value < (@count - 1) / 2
row_number() over(order by U.V) value
numbers cross apply (select 1 V) U;
Do you have a better solution?