sql server查询索引碎片

--检查索引碎片

--检查索引碎片
USE AppsDB
GO

SELECT DB_NAME(ips.database_id) DBName,
	   OBJECT_NAME(ips.object_id) ObjName,
	   i.name IndexName,
	   ips.avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats(DB_ID('AppsDB'),
	DEFAULT,DEFAULT,DEFAULT,default) ips
INNER JOIN sys.indexes i
ON	ips.index_id = i.index_id AND
	ips.object_id = i.object_id
WHERE 
	ips.object_id>99 AND
	ips.avg_fragmentation_in_percent>=10 AND
    ips.index_id>0

结果显示

sql server查询索引碎片_第1张图片

你可能感兴趣的:(sql)