Index fragmentation.

  • I want to get the index details for all the tables in paricular database and copy it to a table for analysis.

  • You can insert the resultset of below query to any table.

    SELECT ps.database_id, ps.OBJECT_ID,

    ps.index_id, b.name,

    ps.avg_fragmentation_in_percent

    FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS ps

    INNER JOIN sys.indexes AS b ON ps.OBJECT_ID = b.OBJECT_ID

    AND ps.index_id = b.index_id

    WHERE ps.database_id = DB_ID()

    ORDER BY ps.OBJECT_ID

    GO

  • this will help me,Thank you very much .

  • as said earlier, all details are in sys.Indexes.

  • Satya_0000 (1/25/2012)


    this will help me,Thank you very much .

    Welcome 🙂

  • Get and learn to use the AMAZING, FREE maintenance scripts from ola.hallengren.com. Nice documentation with it too.

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply