Can anyone provide me the complete script to check the average fragmentation for each table (with table name) in a DB?
I have tried this but seem only retrive data for one of the table. I would like to show ALL tables.
SELECT a.index_id, name, avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats (DB_ID(), OBJECT_ID(N'xxxx.master'),
NULL, NULL, NULL) AS a
JOIN sys.indexes AS b ON a.object_id = b.object_id AND a.index_id = b.index_id;
View Complete Post