We take one of our production databases and create a copy on another server for read-only purposes. The read-only database is located on SQL Server 2008. After the database is on the new server, we would like to optimize it for read-only use.
One of the problems is that for some of the unused tables there is a large amount of allocated space. Another issue I would expect would be index fragmentation. I am not sure if table fragmentation is a problem.
What are the problems and what is the best way to do this? Are there stored procedures included in SQL Server that will help? I tried to start DBCC SHRINKDATABASE, but this did not free up unused space.
EDIT: The exact command I used to compress the database was
DBCC SHRINKDATABASE (dbname, 0)
GO
This went on for a couple of hours. When I checked the tablespace with sp_spaceused, not a single unused space was freed.
source
share