Author | Adam Lancaster, github.com/lancasteradam |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Remove-DbaDbSequence on GitHub.
Want to see the Bill Of Health for this command? Check out Remove-DbaDbSequence.
Removes database sequence objects from SQL Server instances.
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.
Pipeline input from Get-DbaDbSequence allows for selective removal after review or filtering.
Remove-DbaDbSequence
[-SqlInstance] <DbaInstanceParameter[]>
[-SqlCredential <PSCredential>]
[-Database <String[]>]
[-Sequence <String[]>]
[-Schema <String[]>]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-DbaDbSequence -InputObject <Sequence[]>
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> Remove-DbaDbSequence -SqlInstance sqldev01 -Database TestDB -Sequence TestSequence
Removes the sequence TestSequence in the TestDB database on the sqldev01 instance.
PS C:\> Get-DbaDbSequence -SqlInstance SRV1 | Out-GridView -Title 'Select sequence(s) to drop' -OutputMode Multiple | Remove-DbaDbSequence
Using a pipeline this command gets all sequences on SRV1, lets the user select those to remove and then removes the selected sequences.
The target SQL Server instance or instances.
Alias | |
Required | True |
Pipeline | false |
Default Value |
Accepts sequence objects piped from Get-DbaDbSequence for removal.
This allows you to first review sequences with Get-DbaDbSequence before selectively removing them.
Alias | |
Required | True |
Pipeline | true (ByValue) |
Default Value |
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies which databases to search for sequences to remove. Accepts wildcards for pattern matching.
Use this to limit sequence removal to specific databases instead of searching all databases on the instance.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies the name(s) of the sequences to remove. Accepts wildcards for pattern matching.
Use this when you know the exact sequence names or want to remove sequences matching a naming pattern.
Alias | Name |
Required | False |
Pipeline | false |
Default Value |
Filters sequences to remove by schema name. Accepts wildcards for pattern matching.
Useful when you need to remove sequences from specific schemas only, such as during application module cleanup.
Alias | |
Required | False |
Pipeline | false |
Default Value |
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Shows what would happen if the command were to run. No actions are actually performed.
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
Prompts you for confirmation before executing any changing operations within the command.
This is the default. Use -Confirm:$false to suppress these prompts.
Alias | cf |
Required | False |
Pipeline | false |
Default Value |