-- Esse script retorna suas tabelas, índices, a fragmentação do índice e a densidade de página

	
use seu_banco_de_dados go SELECT OBJECT_NAME ([ips].[object_id]) AS [Object Name], [si].[name] AS [Index Name], ROUND ([ips].[avg_fragmentation_in_percent], 2) AS [Fragmentation], [ips].[page_count] AS [Pages], ROUND ([ips].[avg_page_space_used_in_percent], 2) AS [Page Density] FROM sys.dm_db_index_physical_stats (DB_ID (),NULL,NULL,NULL,N'DETAILED') [ips] CROSS APPLY [sys].[indexes] [si] WHERE [si].[object_id] = [ips].[object_id] AND [si].[index_id] = [ips].[index_id] AND [ips].[index_level] = 0 AND [ips].[alloc_unit_type_desc] = N'IN_ROW_DATA'; GO