Thor Logo dbatools

Database

Remove-DbaDatabase

Chrissy LeMaire (@cl), netnerds.net

Remove-DbaDatabase View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Removes user databases using multiple fallback methods to handle stuck or locked databases. Description Removes user databases by attempting three different drop methods in sequence until one succeeds. First tries the standard KillDatabase() method, then attempts to set the database to single-user mode with rollback immediate before dropping, and finally uses the SMO Drop() method. This approach handles databases that are stuck due to active connections, replication, mirroring, or other locks that prevent normal removal.

Read more

Remove-DbaDatabaseSafely

Rob Sewell (@SQLDBAWithBeard), sqldbawithabeard.com

Remove-DbaDatabaseSafely View Source Rob Sewell (@SQLDBAWithBeard), sqldbawithabeard.com Windows, Linux, macOS Synopsis Removes databases after creating verified backups and testing restore procedures. Description Performs a comprehensive database removal workflow that validates database integrity, creates verified backups, and tests restore procedures before permanently removing databases. This function runs DBCC CHECKDB to verify database health, creates a checksummed backup to a specified location, generates a SQL Agent job for automated restore testing, drops the original database, executes the restore job to verify backup integrity, performs another DBCC check on the restored database, and finally removes the test database.

Read more

Remove-DbaDbBackupRestoreHistory

IJeb Reitsma

Remove-DbaDbBackupRestoreHistory View Source IJeb Reitsma Windows, Linux, macOS Synopsis Removes backup and restore history records from MSDB database to prevent excessive growth Description Removes backup and restore history records from MSDB database tables to prevent them from consuming excessive disk space and degrading performance. Over time, these history tables can grow substantially on busy SQL Server instances with frequent backup operations. Works in two modes: server-level cleanup removes records older than a specified retention period (default 30 days), while database-level cleanup removes the complete backup/restore history for specific databases.

Read more

Remove-DbaDbCheckConstraint

Mikey Bronowski (@MikeyBronowski), bronowski.it

Remove-DbaDbCheckConstraint View Source Mikey Bronowski (@MikeyBronowski), bronowski.it Windows, Linux, macOS Synopsis Removes check constraints from SQL Server database tables Description Removes check constraints from database tables across one or more SQL Server instances. Check constraints enforce data integrity by validating that column values meet specific criteria before allowing INSERT or UPDATE operations. This function is useful when modifying table schemas, removing outdated business rules, or preparing databases for data migration where existing constraints might block bulk operations.

Read more

Remove-DbaDbPartitionFunction

Mikey Bronowski (@MikeyBronowski), bronowski.it

Remove-DbaDbPartitionFunction View Source Mikey Bronowski (@MikeyBronowski), bronowski.it Windows, Linux, macOS Synopsis Drops partition functions from SQL Server databases to clean up unused partitioning schemes. Description Removes partition functions from specified databases across one or more SQL Server instances. Partition functions define the value ranges used to split table data across multiple filegroups, and removing unused functions helps maintain a clean database schema. This command is commonly used during partition cleanup operations, schema migrations, or when decommissioning partitioned tables that no longer require their associated partition functions.

Read more

Remove-DbaDbPartitionScheme

Mikey Bronowski (@MikeyBronowski), bronowski.it

Remove-DbaDbPartitionScheme View Source Mikey Bronowski (@MikeyBronowski), bronowski.it Windows, Linux, macOS Synopsis Removes database partition schemes from SQL Server databases. Description Removes partition schemes from specified databases across one or more SQL Server instances. Partition schemes define how partitioned tables and indexes map to filegroups, and this function helps clean up unused schemes during database reorganization or migration projects. The function integrates seamlessly with Get-DbaDbPartitionScheme through pipeline support, allowing you to first identify partition schemes and then selectively remove them.

Read more

Remove-DbaDbSchema

Adam Lancaster, github.com/lancasteradam

Remove-DbaDbSchema View Source Adam Lancaster, github.com/lancasteradam Windows, Linux, macOS Synopsis Removes database schemas from one or more SQL Server databases. Description Removes database schemas from SQL Server databases using the DROP SCHEMA T-SQL command. This function is useful for cleaning up unused schemas during database maintenance, development environment resets, or application decommissioning. The schema must be completely empty before removal - any tables, views, functions, or other objects within the schema will prevent the drop operation from succeeding.

Read more

Remove-DbaDbSnapshot

Simone Bizzotto (@niphold)

Remove-DbaDbSnapshot View Source Simone Bizzotto (@niphold) Windows, Linux, macOS Synopsis Drops database snapshots from SQL Server instances Description Removes database snapshots by executing DROP DATABASE statements against the target SQL Server instances. Database snapshots are point-in-time, read-only copies of databases that consume minimal space through copy-on-write technology. This function helps DBAs clean up obsolete snapshots that are no longer needed for reporting, testing, or recovery purposes. The Force parameter can terminate active connections to snapshots that might otherwise prevent the drop operation from succeeding.

Read more

Remove-DbaDbSynonym

Mikey Bronowski (@MikeyBronowski), bronowski.it

Remove-DbaDbSynonym View Source Mikey Bronowski (@MikeyBronowski), bronowski.it Windows, Linux, macOS Synopsis Removes database synonyms from SQL Server databases Description Removes one or more database synonyms from SQL Server databases by executing DROP SYNONYM commands. Synonyms are database objects that provide alternate names for tables, views, or other objects, often used to simplify complex object names or provide abstraction layers. This function helps clean up obsolete synonyms during database refactoring, migrations, or general maintenance activities, so you don’t have to manually script DROP statements across multiple databases or instances.

Read more

Remove-DbaDbTable

Andreas Jordan (@JordanOrdix), ordix.de

Remove-DbaDbTable View Source Andreas Jordan (@JordanOrdix), ordix.de Windows, Linux, macOS Synopsis Drops tables from SQL Server databases with safety controls and detailed status reporting. Description Permanently removes tables from one or more databases using SQL Server Management Objects (SMO). This function provides a safer alternative to manual DROP TABLE statements by including built-in confirmation prompts and comprehensive error handling. You can specify tables directly by name or pipe table objects from Get-DbaDbTable for more complex filtering scenarios.

Read more
Page 6 of 8