DECLARE @lowInclusive INT = 3 DECLARE @highInclusive INT = 55 -- Declare a common table expression ;WITH generator AS ( -- In the base case, just select our first number as a row SELECT number FROM (VALUES(@lowInclusive)) AS base(number) UNION ALL -- Now select recursively from the common table until we reach our high number SELECT number + 1 FROM generator WHERE number < @highInclusive ) SELECT * FROM generator