MS SQL Index reorganisieren

USE EVVSEVVaultStore01_1;

GO

— Find the average fragmentation percentage of all indexes

— in the HumanResources.Employee table.

SELECT a.index_id, name, avg_fragmentation_in_percent

FROM sys.dm_db_index_physical_stats (DB_ID(N’EVVSEVVaultStore01_1′),
OBJECT_ID(N’HumanResources.Employee‘), NULL, NULL, NULL) AS a

JOIN sys.indexes AS b ON a.object_id = b.object_id AND a.index_id =
b.index_id

order by avg_fragmentation_in_percent DESC;

GO

USE EVVSEVVaultStore01_1;

GO

— Reorganize all indexes on the HumanResources.Employee table.

ALTER INDEX ALL ON dbo.journalarchive

REORGANIZE ;

GO