Using SQL 2008 R2.
I am running the following query to find fragmented indexes for rebuild and update statistics. It returns some records with null index name. What should I do with those? Do they need to be rebuilt for performance? How?
SELECT top 50 dbschemas.[name] as 'SchemaName', dbtables.[name] as 'TableName', dbindexes.[name] as 'IndexName', indexstats.avg_fragmentation_percent, indexstats.page_count, getdate() AS loaddate INTO #temp FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS indexstats INNER JOIN sys.tables dbtables on dbtables.[object_id] = indexstats.[object_id] INNER JOIN sys.schemas dbschemas on dbtables.[schema_id] = dbschemas.[schema_id] INNER JOIN sys.indexes AS dbindexes ON dbindexes.[object_id] = indexstats.[object_id] AND indexstats.index_id = dbindexes.index_id WHERE indexstats.database_id = DB_ID() and indexstats.page_count > 1000 and indexstats.avg_fragmentation_in_percent > 30
Thanks in advance for you help.