Recriando índices
Veja como é fácil recriar índices
Essa é uma dica para desenvolver recriar índices.
Script simples para recriar todos os índices de todas as tabelas:
Foi utilizado o comando ALTER INDEX pois o comando DBCC DBREINDEX será retirado nas versões futuras.
DECLARE @Tabela varchar(100)
DECLARE CTable CURSOR FOR SELECT name FROM sysobjects WHERE xtype = 'U'
OPEN CTable FETCH NEXT FROM CTable INTO @Tabela
WHILE @@FETCH_STATUS = 0 BEGIN PRINT 'Reconstruindo Índices da tabela ' + UPPER(@Tabela) EXEC ('ALTER INDEX ALL ON [' + @Tabela + '] REBUILD') FETCH NEXT FROM CTable INTO @Tabela
END
PRINT ' ' PRINT 'FIM'
CLOSE CTable DEALLOCATE CTable
Espero ter ajudado.
Related articles
Short: SQL Update using begin try and begin transaction
Commit and Rollback command
Getting the last 120 months of data from my database
how to do it in SQL language?
How to create a variable to use the IN clause SELECT query SQL?
Database code part
Ozimar Henrique