Detect Table Fragmentation in SQL Server 2005

  • Hi Ola,

    I tried using your IndexOptimize, but it didn't return any results against my database which is running on compatibility level of 80. I don't think said comp. level is supported in this script, isn't it? Can you have it customized for such databases, please?

    Thanks in advance!

    OptraDBA

  • It is only the database that you are creating the objects in, that has to be in compatibility level 90 or 100. All other databases can be in any compatibility level.

    I think that if you're experiencing that no indexes are being rebuilt or reorganized it's because of that your indexes have low fragmentation or are to small. Try setting @PageCountLevel = 1 or something as a test to see if that changes anything.

    Ola Hallengren

    http://ola.hallengren.com

  • I tried to execute the query,

    SELECT OBJECT_NAME(i.object_id) AS TableName, i.name AS IndexName,

    indexstats.avg_fragmentation_in_percent

    FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, 'DETAILED') indexstats

    INNER JOIN sys.indexes i ON i.object_id = indexstats.object_id

    AND i.index_id = indexstats.index_id

    but I keep getting this error "Incorrect syntax near '('.

    Please help me resolve.

  • I think that it's because the database you're in is not in compatibility level 90 or higher.

    EXECUTE dbo.sp_dbcmptlevel @dbname=N'DatabaseName', @new_cmptlevel=90

    Ola Hallengren

    http://ola.hallengren.com

Viewing 4 posts - 31 through 33 (of 33 total)

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