Telefon
Telegram
WhatsApp
İnstagram
Database İndex

Database İndex

Database İndex

Database İndex

DECLARE @IndexName VARCHAR(100) DECLARE @TABLENAME VARCHAR(100) DECLARE DONGU CURSOR FOR SELECT OBJECT_NAME (ps.object_id) as TABLENAME, i.name as IndexName FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL , NULL, 'LIMITED') ps INNER JOIN sys.indexes i ON i.object_id=ps.object_id and i.index_id=ps.index_id WHERE --OBJECT_NAME (ps.object_id) LIKE '%001%' AND avg_fragmentation_in_percent >= 10 AND ps.index_id > 0 ORDER BY OBJECT_NAME (ps.object_id),i.name OPEN DONGU FETCH NEXT FROM DONGU INTO @TABLENAME,@IndexName WHILE @@FETCH_STATUS = 0 BEGIN     PRINT 'Index yapilan tablo adı = dbo.' + @TABLENAME + ' index adı ' + @IndexName                 EXEC (' ALTER INDEX ' + @IndexName + ' ON dbo.' + @TABLENAME + '  REBUILD')                 EXEC (' ALTER INDEX ' + @IndexName + ' ON dbo.' + @TABLENAME + '  REORGANIZE')     FETCH NEXT FROM DONGU INTO @TABLENAME,@IndexName END  CLOSE DONGU DEALLOCATE DONGU
Paylaş: