--
-- $Id: ReIndexAll.sql 84480 2007-07-24 06:34:27Z pca $
--
-- Reindex and shrink the ManageSoft database.
-- On a large database, this can take many hours.
--
use ManageSoft

DECLARE @cmd VARCHAR(512)

DECLARE c CURSOR FOR
SELECT	'DBCC DBREINDEX ('''+sysobjects.name+''')'
FROM	sysobjects WHERE xtype = 'U'

OPEN c
FETCH NEXT FROM c INTO @cmd
WHILE @@FETCH_STATUS = 0
BEGIN
	EXEC(@cmd)
	FETCH NEXT FROM c INTO @cmd
END
CLOSE c
DEALLOCATE c

DBCC SHRINKDATABASE (ManageSoft)
