SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

SQL 2008 : Uncompressed Objects Procedure

By Richard Doering,

Introduction :

First of all, I've already evaluated and am using SQL 2008 Table & Index Compression.

This procedure is to help you to do the same. Obviously if you're reading this you're most likely a DBA and will dutifully evaluate whether compression is appropriate for your environment. Personally I'm very impressed and feel the storage savings far outweigh the additional processor overhead.

Usage :

UncompressedObjects has 2 required parameters, @database and @compressiontype.

@database is the name of the database you want to compress.
@compressiontype is either PAGE or ROW compression.

There are 2 optional parameters @emailrecipients and @emailprofile.
If these are both supplied, the output is sent to the email addresses supplied (providing you have an email profile configured).

Output :

The procedure provides >

  1. Lists of tables & indexes without compression
  2. Lists of tables & indexes not using the desired compression (e.g. ROW when you've specified a compression type of PAGE)
  3. TSQL commands to compress the database objects.

Examples :

EXEC dbo.UncompressedObjects
@database = 'MyDatabase'
, @compressiontype = 'ROW'

EXEC dbo.UncompressedObjects
@database = 'Adventureworks'
, @compressiontype = 'PAGE'
, @emailrecipients = 'emailaddress@domain.com'
, @emailprofile = 'Profile Name'

NB :

I've also supplied stored procedure 'UncompressedServerObjects' which simply executes UncompressedObjects for each user database. I schedule this via SQL Agent so I know if objects are created without compression.


I hope people find this script useful.

Richard Doering


Total article views: 705 | Views in the last 30 days: 2
Related Articles

Script to Compress Tables and Indexes

This script creates scripts to compress all tables and indexes in a database.


Compress tables

It compresses all the tables/indexes in a database, a specific one or all the objects inside a datab...


Script for compressing a database

When you have to compress a database you’d better first see the consideration for the compression. ...


A Script A Day - Day 9 - Index Compression Estimations

Today's script provides amongst other information Index compression estimates based on existing inde...


SQL Server 2008 Compression

Testing and analysis of new backup compression and table/index compression features of SQL Server 20...