GENERATE_SERIES
number series generator
What changes
- Input
- start, stop, optional step
- Output or change
- single-column rowset named value
- Return type
- Returns a single-column table containing a sequence of values in which each differs from the preceding by step. The name of the column is value. The output is the same type as start and stop.
Syntax at a glance
GENERATE_SERIES ( start , stop [ , step ] )
Work example
A report needs a bounded numeric sequence without a permanent numbers table.
Run a short start and stop range. Add a step only after checking that it moves toward the bound.
Check your work GENERATE_SERIES. The values include the expected endpoints and the sequence stops at the requested bound.
Practice SQL
Open in SQL FlowSELECT value FROM GENERATE_SERIES(1, 4) ORDER BY value;
Open Microsoft Learn for full syntax, permissions, and details for your version.