This Script is reusing a script from Eli Leiba published here: https://www.mssqltips.com/sqlservertip/2381/sql-server-data-compression-storage-savings-for-all-tables/  and extends it to also generate the compression-script where the saving-rate exceeds a certain threshold (in the script below the threshold is 20%) –DISCLAIMER: –This code is not supported under any Microsoft standard support program or service. –This code and information are provided