Search This Blog

Thursday 30 July 2015

Rebuild index in sql server Or rebuild index

Run the following script changing the XYZ for the database name, run against the master.

SELECT 'dbcc dbreindex(''XYZ.DBO.' +name+ ''')'
FROM sysobjects WHERE xtype='U'

This will generate a rebuild statement for each index, copy the output of the results window and paste it into the Query Analyzer window and run against the right database.
This can obviously be repeated for each database as required.


No comments:

Post a Comment