-- TABLES
SELECT distinct st.name, st.object_id, schema_name(schema_id), 'ALTER TABLE ' + schema_name(schema_id) + '.' + st.name + ' REBUILD WITH (DATA_COMPRESSION = NONE)'--, sp.partition_id, sp.partition_number, sp.data_compression, sp.data_compression_desc
FROM sys.partitions SP
INNER JOIN sys.tables ST ON st.object_id = sp.object_id
WHERE data_compression <> 0
and index_id = 1
-- INDEXES -- DROP AND CREATE INDEX WITH "DATA_COMPRESSION = NONE"
SELECT distinct st.name, st.object_id, schema_name(schema_id), i.name
FROM sys.partitions SP
INNER JOIN sys.tables ST ON st.object_id = sp.object_id
join sys.sysindexes i on SP.object_id = i.id and SP.index_id = i.indid
WHERE data_compression <> 0
and index_id <> 1
No comments:
Post a Comment