For rebuilding ServiceRequestAttribute on REX (Short lived):
ALTER INDEX IX_ServiceRequestAttribute ON dbo.ServiceRequestAttribute REBUILD WITH (ONLINE=ON) GO ALTER INDEX PK_ServiceRequestAttribute ON dbo.ServiceRequestAttribute REBUILD WITH (ONLINE=ON) GO ALTER INDEX IDX_ServiceRequestAttribute_AttributeName ON dbo.ServiceRequestAttribute REBUILD WITH (ONLINE=ON) GO UPDATE STATISTICS dbo.ServiceRequestAttribute GO
For rebuilding ServiceRequestAttribute on RE (will be addressed with a KTLO story):
This script will tell you which partitions to maintain, > 30 Rebuild, > 10 Reorganize (this script may take a while to run but saves time in the long haul)
DECLARE @objectId AS INT; DECLARE @indexId AS INT; SELECT @objectId = object_id FROM [sys].[tables] WHERE [name] = 'ServiceRequestAttribute' SELECT @indexId = index_id FROM [sys].[indexes] WHERE object_id = @objectId AND type_desc = 'CLUSTERED' SELECT OBJECT_NAME(ips.OBJECT_ID) ,i.NAME ,ips.index_id ,ips.partition_number ,index_type_desc ,avg_fragmentation_in_percent ,avg_page_space_used_in_percent ,page_count ,ips.record_count FROM sys.dm_db_index_physical_stats(DB_ID(), @objectId, @indexId, NULL, NULL) ips INNER JOIN sys.indexes i ON (ips.object_id = i.object_id) AND (ips.index_id = i.index_id) ORDER BY index_id,ips.partition_number,avg_fragmentation_in_percent DESC
--Build scripts for individual partitions accordingly using these as templates and Update statistics at the end ALTER INDEX ALL ON coordinator.ServiceRequestAttribute REBUILD PARTITION = 1 WITH (ONLINE=ON) GO ALTER INDEX ALL ON coordinator.ServiceRequestAttribute REORGANIZE PARTITION = 1 GO UPDATE STATISTICS coordinator.ServiceRequestAttribute GO