USE [sandbox]

SELECT 
       OBJECT_NAME([OBJECT_ID]) AS [object_name],
       [object_id],
       [index_id],
       [partition_number],
       [row_group_id],
       [delta_store_hobt_id],
       [state],
       [state_desc],
       [total_rows],
       [deleted_rows],
       [size_in_bytes],
       [size_in_bytes]/1024.0/1024.0 AS size_in_mb,
       
       [trim_reason],
       [trim_reason_desc],
       [transition_to_compressed_state],
       [transition_to_compressed_state_desc],
       [has_vertipaq_optimization],
       [generation],
       [created_time],
       [closed_time]
  FROM sys.dm_db_column_store_row_group_physical_stats
 WHERE 1=1
 --AND object_id = OBJECT_ID('logcheck_products')
 AND [state] IN (
    1, --open
    2 --closed
 )
 ;

RETURN

USE sandbox

ALTER INDEX ALL ON cds_log REORGANIZE;
ALTER INDEX ALL ON logcheck REORGANIZE;
ALTER INDEX ALL ON logcheck_products REORGANIZE;
ALTER INDEX ALL ON logcheck_interactions REORGANIZE;
ALTER INDEX ALL ON patient_risk REORGANIZE;

