CREATE PROCEDURE sp_DBReindex AS SET NOCOUNT ON DECLARE @TableName char(32) DECLARE SysCur CURSOR FOR S_elect name FROM sysobjects WHERE type='U' OPEN SysCur FETCH NEXT FROM SysCur INTO @TableName WHILE @@FETCH_STATUS=0 BEGIN DBCC DBREINDEX(@TableName) FETCH NEXT FROM SysCur INTO @TableName END CLOSE SysCur DEALLOCATE SysCur