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


Set-DbaDbCompression

This function set the appropriate compression recommendation.
Remember Uptime is critical, the longer uptime, the more accurate the analysis is.
You would probably be best if you utilized Get-DbaUptime first, before running this command.

Set-DbaDbCompression script derived from GitHub and the tigertoolbox
(https://github.com/Microsoft/tigertoolbox/tree/master/Evaluate-Compression-Gains)

Screenshots

dbatools - Set-DbaDbCompression

Examples

Set the compression run time to 60 minutes and will start the compression of tables/indexes that have a difference of 25% or higher between current and recommended.

Set-DbaDbCompression -SqlInstance localhost -MaxRunTime 60 -PercentCompression 25

Set the compression run time to 60 minutes and will start the compression of tables/indexes that have a difference of 25% or higher between current and recommended and the results into a nicely formatted GridView.

Set-DbaDbCompression -SqlInstance ServerA -Database DBName -MaxRunTime 60 -PercentCompression 25 | Out-GridView

Returns results of all potential compression options for all databases with the recommendation of either Page or Row

$cred = Get-Credential sqladmin
Set-DbaDbCompression -SqlInstance ServerA -ExcludeDatabase Database -SqlCredential $cred -MaxRunTime 60 -PercentCompression 25

Author

This command was created by Jason Squires. You can find Jason on Twitter.

Get-Help

From PowerShell, execute Get-Help Set-DbaDbCompression -Detailed for more information on this function.

Source Code

Want to see the source code? View Set-DbaDbCompression.ps1 on GitHub
 

Related commands