Thor Logo dbatools

Sequence

Get-DbaDbSequence

Adam Lancaster, github.com/lancasteradam

Get-DbaDbSequence View Source Adam Lancaster, github.com/lancasteradam Windows, Linux, macOS Synopsis Retrieves SQL Server sequence objects and their configuration details from specified databases. Description Retrieves sequence objects from SQL Server databases, returning detailed information about each sequence including data type, start value, increment value, and schema location. Sequences provide a flexible alternative to IDENTITY columns for generating sequential numeric values, allowing values to be shared across multiple tables and offering more control over numbering behavior.

Read more

New-DbaDbSequence

Adam Lancaster, github.com/lancasteradam

New-DbaDbSequence View Source Adam Lancaster, github.com/lancasteradam Windows, Linux, macOS Synopsis Creates a new sequence object in SQL Server databases with configurable properties and data types. Description Creates a new sequence object in one or more SQL Server databases, providing an alternative to IDENTITY columns for generating sequential numbers. This function allows you to configure all sequence properties including data type (system or user-defined), starting value, increment, min/max bounds, cycling behavior, and cache settings.

Read more

Remove-DbaDbSequence

Adam Lancaster, github.com/lancasteradam

Remove-DbaDbSequence View Source Adam Lancaster, github.com/lancasteradam Windows, Linux, macOS Synopsis Removes database sequence objects from SQL Server instances. Description Removes sequence objects from SQL Server databases, freeing up schema namespace and cleaning up unused database objects. Sequences are commonly used for generating unique numeric values and may need removal during application changes or database cleanup. When used without a pipeline, the function will first retrieve matching sequences using Get-DbaDbSequence with the provided parameters, then remove them.

Read more

Select-DbaDbSequenceNextValue

Adam Lancaster, github.com/lancasteradam

Select-DbaDbSequenceNextValue View Source Adam Lancaster, github.com/lancasteradam Windows, Linux, macOS Synopsis Retrieves and increments the next value from a SQL Server sequence object. Description Executes a SELECT NEXT VALUE FOR statement against the specified sequence, which increments the sequence counter and returns the next value in the series. This is useful for testing sequence behavior, troubleshooting sequence issues, or retrieving sequence values for application logic. Note that calling this function will permanently increment the sequence counter, so it’s not just a read operation.

Read more

Set-DbaDbSequence

Adam Lancaster, github.com/lancasteradam

Set-DbaDbSequence View Source Adam Lancaster, github.com/lancasteradam Windows, Linux, macOS Synopsis Modifies properties of existing SQL Server sequence objects Description Modifies existing SQL Server sequence objects by updating their properties such as increment value, restart point, minimum and maximum bounds, cycling behavior, and cache settings. This function is essential when you need to adjust sequence behavior after deployment, fix increment issues, or optimize performance without recreating the sequence and losing its current state.

Read more