SQL Flow Field Guide

NEXT VALUE FOR

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

sequence generation

What changes

Input
sequence object state
Output or change
next number per row; sequence advanced
Return type
Returns a number using the type of the sequence.

Syntax at a glance

NEXT VALUE FOR [ database_name . ] [ schema_name . ] sequence_name [ OVER (<over_order_by_clause>) ]

Work example

Request a value from a configured sequence for a new row identifier.

Use schema-qualified names and test missing and permission-hidden objects separately.

Check your work Sequence values are not gapless and are not restored by transaction rollback.

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