I prefer this simple and elequent way to generate numbers.
I doesn't generate unnecessary numbers and is easy to understand
[font="Courier New"]CREATE FUNCTION dbo.GetSequence
(
@Start BIGINT,
@End BIGINT,
@Increment BIGINT
)
RETURNS @ret TABLE(Number BIGINT)
AS
BEGIN
WITH
seq(num)
as
(
select @Start
union all
select num + @Increment from seq
where num + @Increment <= @End
)
INSERT INTO @ret(Number)
Select * From Seq
END[/font]