In the database, due to the import of data, and the accumulation of historical data, the performance of the database gradually declines, and sometimes the index label does not exist, and the database should be reconstructed to improve the performance.
--- Rebuild the index of the entire database Proc (Just for SQL Server2000)
create procedure ReindexAllTable (@dbname sysname) asif object_id ( 'tempdb .. # tableT') is not null drop table #tableTcreate table #tableT (tn sysname) insert into #tableT exec ( 'select name from' @ dbname '.. sysobjects where xtype = ' ' '' ' ' U ' ' '' ') declare tableCrusor cursor for select tn from #tableTopen tableCrusor declare @table sysnamefetch next from tableCrusor into @tablewhile @@ fetch_status = 0beginset @table = @ dbname '.dbo.' @tabledbcc dbreindex (@table) Fetch next from TableCrusor Into @tablendclose TableCrusor Deallocate TableCrusor