Excessive reserved space on SQL Server

Paul G picture Paul G · Sep 2, 2009 · Viewed 12.4k times · Source

We have a database running under MSDE (SQL 2000, service pack 4) that is reserving massive amounts of excess space. Using sp_spaceused for each table gives a total reserved size of 2102560 KB, a data size of 364456 KB and an unused size of 1690760 KB (i.e. reserving nearly 4 times the used space). The worst culprits are tables that are frequently written to but never deleted from (transaction logging). Generally, deletes are very infrequent and very small in terms of size and number of records.

The database files on disk are at the 2 gb limit and this is causing problems with backups etc.

I have tried DBCC SHRINKDATABASE, DBCC SHRINKFILE and DBCC REINDEX with no effect on the file size used on the disk

2 questions - How can I shrink the database file size and how can I stop SQL Server from reserving the excess space ?

Thanks

Paul

Answer

Russell Steen picture Russell Steen · Sep 2, 2009

USE < DBNAME >
GO
BACKUP LOG < DBNAME > WITH TRUNCATE_ONLY
GO
DBCC SHRINKDATABASE ( < DatabaseName > )
GO
DBCC SHRINKFILE (< logfile >, 5)
GO
DBCC SHRINKFILE (< datafile >, 5)
GO

if you don't know the file paths exec sp_helpfile