Compress all tables

As part of my management of our MDW I wrote this to help compress the user-table in the database.

SELECT 'ALTER TABLE ' + s.name + '.' + t.name + ' REBUILD PARTITION = ALL WITH (DATA_COMPRESSION = PAGE)' 
FROM sys.tables AS t
INNER JOIN sys.schemas AS s
ON t.[schema_id] = s.[schema_id]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s