dbatools is a free PowerShell module with over 200 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Invoke-DbaDatabaseUpgrade

Updates compatibility level, then runs CHECKDB with data_purity, DBCC updateusage, sp_updatestats and finally sp_refreshview against all user views.

Screenshots

dbatools - Invoke-DbaDatabaseUpgrade

Examples

Runs the below processes against the databases
— Puts compatibility of database to level of SQL Instance
— Runs CHECKDB DATA_PURITY
— Runs DBCC UPDATESUSAGE
— Updates all users statistics
— Runs sp_refreshview against every view in the database

Invoke-DbaDatabaseUpgrade -SqlInstance PRD-SQL-MSD01 -Database Test

Runs the upgrade command skipping the sp_refreshview update on all views.

Invoke-DbaDatabaseUpgrade -SqlInstance PRD-SQL-INT01 -Database Test -NoRefreshView

If database Test is already at the correct compatibility, runs every necessary step.

Invoke-DbaDatabaseUpgrade -SqlInstance PRD-SQL-INT01 -Database Test -Force

Get only specific databases using GridView and pass those to Invoke-DbaDatabaseUpgrade.

Get-DbaDatabase -SqlInstance sql2016 | Out-GridView -Passthru | Invoke-DbaDatabaseUpgrade

Author

This command was created by Stephen Bennett. You can find Stephen on his blog.

Get-Help

From PowerShell, execute Get-Help Invoke-DbaDatabaseUpgrade -Detailed for more information on this function.

Source Code

Want to see the source code? View Invoke-DbaDatabaseUpgrade.ps1 on GitHub
 

Related commands