with stats as ( SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'fmCopyDistributors'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'fmCopyItems'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'fmCopyItemsMergedActivityLog'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'fmCopyManufacturerItemCategories'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'fmCopyManufacturers'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'fmFSEchangeLog'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'fmWorkDistributorItemCodes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_AllergenInfo'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Allergens'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_AllergenTypes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_AttributeLinks'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Attributes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_AttributeTypes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_BuiltInFields'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Categories'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_CategoryTypes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Changes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_ClassTypes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_CustomerLocales'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_CustomerSkus'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_CustomerSkus_backup'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_CustomerSkusStage'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_CustomFlds'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_DataProviders'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_DistributorSkus'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_FieldLookups'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Fields'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_FieldValues'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Hierarchy'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Images'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Incentives'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_KosherTypes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_ListItems'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Lists'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_MarketingDescriptions'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Memo'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_MemoTypes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Nutrition'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_NutritionalClaimInfo'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_NutritionalClaims'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_NutritionalClaimTypes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_NutritionalFactPanel'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_NutritionChild'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_OtherAttributes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Packaging'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_PriceListBrackets'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_PriceListPrices'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_PriceLists'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_ProductImages'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Products'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_ProductTypes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_ProfileCheckpoint'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_RecommendedTargetVolumes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Repository'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_RepositoryCategories'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_SaleAuditRules'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_SalesChannels'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Settings'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_SkuDeletes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_SkuRequest'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_SkuRequestLink'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_SKUs'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Specsheets'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Subscribers'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Subscriptions'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_SubUnitTypes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_SyndicationSetContents'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_SyndicationSets'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_SyndicationSuppressions'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_TradeChannelLink'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_TradeChannels'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_UnitMeasureTypes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_VarietyPackLink'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_VarietyPacks'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_PRD_Videos'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_AccrualHistory'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_Accruals'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_AgreementComponents'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_AgreementStatuses'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_ArchivedClaims'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_BostonClaimHistory'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_Budgets'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_BudgetTypes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_CheckRequests'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_ClaimantAutoAuditOptions'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_ClaimContracts'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_claimDataDW'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_ClaimHistory'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_ClaimLog'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_ClaimProcessingRestrictions'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_Claims'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_ClaimStatusReasons'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_ContractReferences'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_Contracts'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_CriticalIssuesToIgnore'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_CriticalIssueTypes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_EAI_ClaimFaults'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_ExternalClaimHistory'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_GeneralLedgerAccounts'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_OperatorClaimMappings'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_PartnerPayables'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_ProofOfDelivery'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_ProofOfDeliveryManifest'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_ReconciliationHistory'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_RepaymentLog'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_Repository'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_RepositoryCategories'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_RequestApprovers'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_RequestExclusions'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_RequestModels'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_RequestPartners'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_RequestProducts'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_Requests'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_RequestSkus'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_RequestTypeApprovalLevels'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_RequestTypeComponents'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_RequestTypes'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_Settings'), NULL, NULL , 'LIMITED') s union all SELECT ( select t.name from sys.tables t where t.object_id = s.object_id ) tableName, ( select i.name from sys.indexes i where i.object_id = s.object_id and i.index_id = s.index_id ) indexName, s.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats( DB_ID(N'FSLibrary_RPC'), OBJECT_ID(N'tbl_TPM_Thresholds'), NULL, NULL , 'LIMITED') s ) select *, 'alter index [' + indexName + '] on [' + tableName + '] reorganize;' as reorg from stats where avg_fragmentation_in_percent > 0 order by avg_fragmentation_in_percent desc