Does anyone happen to have a generic SQL statement that\'ll list all of the tables and indexes in a database, along with their current compression setting, for each partition?>
This should do the job, test it for a small subset to be sure it gives you what you need
SELECT DISTINCT s.name [Schema], t.name [Table], i.name [Index Name], p.partition_number, p.data_compression_desc
-- uncommenting the below line will give you dupes
--, p.index_id
FROM sys.schemas s
INNER JOIN sys.tables t
ON s.schema_id = t.schema_id
INNER JOIN sys.indexes i
ON t.object_id = i.object_id
INNER JOIN sys.partitions p
ON t.object_id = p.object_id
ORDER BY s.name, t.name
The reason you are probably getting dupes is because you have multiple partition records per table, e.g. multiple index_id, see this MSDN article for clarification on what the index_id's mean. Adding a DISTINCT should solve the problem of the dupes