Remove-DbaDbUdf View Source Mikey Bronowski (@MikeyBronowski), bronowski.it Windows, Linux, macOS Synopsis Removes user-defined functions from SQL Server databases.
Description Removes user-defined functions from specified databases, providing a clean way to drop obsolete or unwanted UDFs without manual T-SQL scripting. This function is particularly useful during database cleanup operations, code refactoring projects, or when removing deprecated functions that are no longer needed. Supports filtering by schema and function name, and can exclude system UDFs to prevent accidental removal of built-in functions.
Remove-DbaDbView View Source Mikey Bronowski (@MikeyBronowski), bronowski.it Windows, Linux, macOS Synopsis Removes database views from SQL Server databases
Description Removes one or more database views from specified databases and SQL Server instances. This function streamlines the cleanup of obsolete views during database refactoring, development cleanup, or schema maintenance tasks. You can specify views individually by name or use pipeline input from Get-DbaDbView for bulk operations. Each removal operation includes detailed status reporting and supports WhatIf testing to preview changes before execution.
Rename-DbaDatabase View Source Simone Bizzotto (@niphold) Windows, Linux, macOS Synopsis Renames database names, filegroups, logical files, and physical files using customizable templates with placeholder support.
Description Systematically renames all database components using template-based naming conventions to enforce consistent standards across your SQL Server environment.
This function addresses the common challenge of standardizing database naming when inheriting inconsistent systems or implementing new naming policies.
The renaming process follows SQL Server’s object hierarchy and executes in this order:
Restore-DbaDbSnapshot View Source Simone Bizzotto (@niphold) Windows, Linux, macOS Synopsis Restores SQL Server databases from database snapshots, reverting to the snapshot’s point-in-time state
Description Restores SQL Server databases to their exact state when a database snapshot was created, discarding all changes made since that point. This is particularly useful for quickly reverting development databases after testing, rolling back problematic changes, or returning to a known good state without restoring from backup files.
Set-DbaDbCompatibility View Source Garry Bargsley, blog.garrybargsley.com Windows, Linux, macOS Synopsis Changes database compatibility levels to match SQL Server instance version or specified target level.
Description Updates database compatibility levels across one or more SQL Server instances. When no specific compatibility level is provided, automatically sets each database to match the SQL Server instance version it resides on. This is particularly useful after SQL Server upgrades when databases retain their original compatibility levels and need updating to take advantage of newer engine features and optimizations.
Set-DbaDbCompression View Source Jason Squires (@js_0505), [email protected] Windows, Linux, macOS Synopsis Applies data compression to SQL Server tables and indexes to reduce storage space and improve performance.
Description Compresses tables, indexes, and heaps across one or more databases using Row, Page, or intelligent recommendations based on Microsoft’s Tiger Team compression analysis. Automatically handles the complex process of analyzing usage patterns, applying appropriate compression types, and rebuilding objects online when possible.
Set-DbaDbOwner View Source Michael Fal (@Mike_Fal), mikefal.net Windows, Linux, macOS Synopsis Changes database ownership to a specified login when current ownership doesn’t match the target.
Description Changes database ownership to standardize who owns your databases across an instance. This is particularly useful for maintaining consistent ownership patterns after restoring databases from other environments, where databases may have orphaned owners or inconsistent ownership.
By default, the function sets ownership to ‘sa’ (or the renamed sysadmin account), but you can specify any valid login.
Set-DbaDbRecoveryModel View Source Viorel Ciucu (@viorelciucu), cviorel.com Windows, Linux, macOS Synopsis Changes the recovery model for specified databases on SQL Server instances.
Description Changes the recovery model setting for one or more databases, allowing you to switch between Simple, Full, and BulkLogged recovery modes. This is commonly used when preparing databases for different backup strategies, reducing transaction log growth in development environments, or configuring production databases for point-in-time recovery. The function excludes tempdb and database snapshots automatically, and requires explicit database specification for safety.
Set-DbaDbSchema View Source Adam Lancaster, github.com/lancasteradam Windows, Linux, macOS Synopsis Changes the owner of database schemas to reassign security and object ownership responsibilities
Description Modifies the ownership of database schemas by updating the schema owner property in SQL Server. This is commonly needed when reorganizing database security, transferring ownership from developers to service accounts, or standardizing schema ownership after database migrations. The function works by retrieving the schema object and updating its Owner property through SQL Server Management Objects, then applying the change to the database.
Set-DbaDbState View Source Simone Bizzotto (@niphold) Windows, Linux, macOS Synopsis Modifies database read/write access, online status, and user access modes
Description Modifies database access modes and availability states through ALTER DATABASE commands, eliminating the need to write T-SQL manually for common database administration tasks.
This function handles three categories of database state changes:
Read/Write access: Sets databases to READ_ONLY for reporting scenarios or READ_WRITE for normal operations Online status: Brings databases ONLINE, takes them OFFLINE for maintenance, or sets EMERGENCY mode for corruption recovery User access: Restricts database access to SINGLE_USER for maintenance, RESTRICTED_USER for admin-only access, or MULTI_USER for normal operations Database detachment: Safely detaches databases by first removing them from Availability Groups and breaking mirroring relationships when -Force is specified The -Force parameter rolls back open transactions immediately, allowing state changes to proceed even when active connections exist.