USE Realiz2009; DECLARE @TableName varchar(255); DECLARE _cursor CURSOR FOR SELECT name FROM sysobjects WHERE (type = 'U'); OPEN _cursor; FETCH NEXT FROM _cursor INTO @TableName; WHILE @@FETCH_STATUS = 0 BEGIN DBCC DBREINDEX(@TableName); FETCH NEXT FROM _cursor INTO @TableName; END CLOSE _cursor; DEALLOCATE _cursor;