これらの答えはすべてまともで機能します。私は自分の仕事のためにそれを少し装飾したので、少し貢献する時が来たと思いました. このクエリは、Jason の回答からスキーマを追加します (これが必要でした)。また、いくつかの結合の問題を整理し、結果を非常に単純な要約にまとめます。
-- Returns user tables and indexes in a DB and their Compression state
select s.name [Schema], t.name [Table], i.name [Index], p.data_compression_desc Compression
, case when p.index_id in (0, 1) then 'Table' else 'Index' end CompressionObject
from sys.tables t
join sys.schemas s on t.schema_id = s.schema_id
join sys.indexes i on t.object_id = i.object_id
join sys.partitions p on (i.object_id = p.object_id and i.index_id = p.index_id)
where t.type = 'U'
order by 1, 2, p.index_id, 3
これを「作業リスト」として使用して、すべてを圧縮するスクリプトを生成しました。これは、db を Azure VM にリフトシフトしただけであり、パフォーマンスを向上させるために IOPS を削減したいからです。これが誰かを助けることを願っています。