Quantcast
Channel: Software Applications Programming Errors and solutions.
Viewing all articles
Browse latest Browse all 277

Re-indexes all the tables using DBCC BREINDEX command

$
0
0
Summary:
re-indexes all the tables using DBCC BREINDEX command.
This goes and re-indexes all the tables and takes about 7 minutes and make an improvement of 10%

Details:

USE DbName_1 --Enter the name of the database you want to reindex totally
DECLARE @TableName varchar(255) 
DECLARE TableCursor CURSOR FOR 
SELECT YourTableName 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,' ',100) 
FETCH NEXT FROM TableCursor INTO @TableName 
END 
CLOSE TableCursor 
DEALLOCATE TableCursor


ReIndexing All Database Tables at once in SQL Database Server

This is a simple three line command for Re-indexing All Database Tables at once in SQL Database Server. This command is very helpful to improve your database performance by re indexing tables. Its Update Statistics on Tables.

USE YouDatabaseName
GO
EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)"
GO
EXEC sp_updatestats
GO

Viewing all articles
Browse latest Browse all 277

Trending Articles