SPEED: Server is not running as fast as it should be

SQL Server indexes are used to make searching and updating information faster in MS SQL. If your server is slower than you think it should be it can be because an index needs to be rebuilt.

If you know the table that might be slowing you down you can run the following SQL statement on that table. For this example the table in question is DATA. Replace that with the table you need to rebuild.


If you want to rebuild ALL indexes in your database here is a script to do that. This could take quite a while so do not run this during working hours!

DECLARE @TableName varchar(255) 



SELECT table_name FROM information_schema.tables WHERE table_type = 'base table' 


OPEN TableCursor 

FETCH NEXT FROM TableCursor INTO @TableName 



       DBCC DBREINDEX(@TableName,' ',90) 

       FETCH NEXT FROM TableCursor INTO @TableName 


CLOSE TableCursor 


IMPORTANT: USE THIS SCRIPTS AT YOUR OWN RISK! You must be aware of the implications of these SQL statements to use them correctly. Study up on their uses and use them accordingly.