One of my reorg process is select those high fragmentation index, but it gives me many duplicates, anyone could help me to fix it?[quote]SELECT DPS.index_id, QUOTENAME(I.name) Name, QUOTENAME(DB_NAME()) +'.'+ QUOTENAME(OBJECT_SCHEMA_NAME(I.[object_id])) + '.' + QUOTENAME(OBJECT_NAME(I.[object_id])) ObjectName, DPS.avg_fragmentation_in_percent, DPS.fragment_count, DPS.avg_fragment_size_in_pages, DPS.index_depth,FROM sys.dm_db_index_physical_stats (DB_ID(), NULL ,NULL, NULL, NULL) AS DPSINNER JOIN sys.indexes AS I ON DPS.[object_id]= I.[object_id] AND DPS.index_id = I.index_idINNER JOIN sysindexes AS SI with (NOLOCK) ON SI.id = DPS.object_id AND SI.indid = DPS.index_idWHERE DPS.avg_fragmentation_in_percent > 5 and DPS.index_id > 0 and SI. rows > 100 and SI.rows <= 100000ORDER BY DPS.avg_fragmentation_in_percent DESC[/quote]
↧