Help..Help..Did anyone knows the procedure to rebuild Indexes: Using SQL Enterprise Manager or executing a batch Script from DOS command Line?..Please i need an answer ASAP....Thanks.....
Rebuilding Indexes Tips<br>Periodically (weekly or monthly) perform a database reorganization on all the indexes on all the tables in your database. This will rebuild the indexes so that the data is no longer fragmented. Fragmented data can cause SQL Server to perform unnecessary data reads, slowing down SQL Server's performance.<br>If you do a reorganization on a table with a clustered index, any non-clustered indexes on that same table will automatically be rebuilt.<br>Database reorganizations can be done scheduling SQLMAINT.EXE to run using the SQL Server Agent, or if by running your own custom script via the SQL Server Agent (see below). Unfortunately, the DBCC DBREINDEX command will not automatically rebuild all of the indexes on all the tables in a database, it can only work on one table at a time. But if you run the following script, you can index all the tables in a database with ease:<br>--Script to automatically reindex all tables in a database<br><br>USE DatabaseName --Enter the name of the database you want to reindex<br><br>DECLARE @TableName varchar(255)<br><br>DECLARE TableCursor CURSOR FOR<br>SELECT table_name FROM information_schema.tables<br>WHERE table_type = 'base table'<br><br>OPEN TableCursor<br><br>FETCH NEXT FROM TableCursor INTO @TableName<br>WHILE @@FETCH_STATUS = 0<br>BEGIN <br>PRINT "Reindexing " + @TableName<br>DBCC DBREINDEX(@TableName,' ',90)<br>FETCH NEXT FROM TableCursor INTO @TableName<br>END<br><br>CLOSE TableCursor<br><br>DEALLOCATE TableCursor<br>The script will automatically reindex every index in every table of any database you select, and provide a fillfactor of 90%. You can substitute any number you want for the 90 in the above script.<br><br><br>Ok. I hope you enjoy this!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.