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 0 union all select value * 2 + 1 from numbers where value < @count / 2 union all select value * 2 + 2 from numbers where value < (@count - 1) / 2)select row_number() over(order by U.V) valuefrom numbers cross apply (select 1 V) U;
Do you have a better solution?
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u