Difference between revisions of "LabLynx KB:Rebuild indexes on a SQL server database"
From LIMSWiki
Jump to navigationJump to searchShawndouglas (talk | contribs) (Created article.) |
(No difference)
|
Latest revision as of 00:58, 1 October 2011
![]() |
This is an article specific to the Category:LabLynx knowledge base. Its context outside of LabLynx, Inc may not be apparent, thus why it appears inside the LabLynx KB namespace. |
How to rebuild indexes on a SQL server database
This linked article explains the following script: Tips for Rebuilding Indexes
Here is the script to rebuild all of the indexes on all the tables in a SQL server database:
USE DatabaseName --Enter the name of the database you want to reindex DECLARE @TableName varchar(255) DECLARE TableCursor CURSOR FOR SELECT table_name FROM information_schema.tables WHERE table_type = 'base table' OPEN TableCursor FETCH NEXT FROM TableCursor INTO @TableName WHILE @@FETCH_STATUS = 0 BEGIN DBCC DBREINDEX(@TableName,' ',90) FETCH NEXT FROM TableCursor INTO @TableName END CLOSE TableCursor DEALLOCATE TableCursor