SQL Flow Field Guide

GENERATE_SERIES

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

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 Flow
SELECT value FROM GENERATE_SERIES(1, 4) ORDER BY value;

Open Microsoft Learn for full syntax, permissions, and details for your version.