4

We have a need to fit a database in 4GB in order to use SQL Server Express Edition. I started from a 7GB database, and found a lot of unneeded records, and deleted them. After shrinking, the database size is 4.6GB, and 748 MB is free (according to database properties).

However, when I execute exec sp_spaceused, I have interesting results:

DatabaseName    Database_size   unallocation space
xxxxxx          4726.50 MB      765.42 MB
Reserved        Data          index_size      unused
3899472 KB      1608776 KB    1448400 KB      842296 KB

Any ideas, how can I release at least some of this unused space? Also I know table, which occupied it.

Update: is it worth to trying to rebuild table indexes?

ALTER INDEX ALL ON Production.Product REBUILD
0
1

After index recreation, using this command:

ALTER INDEX ALL ON Production.Product REBUILD

and than I run SHRINK command again - end up with 2.5G database.

1
  • Using this command for every table, I finally get 1.4G database, which is good enough.
    – Sergey Osypchuk
    May 5 '10 at 11:03
0

First set recovery mode to simple, make backup and shrink all files (data and logs) seprately; use 'move pages to start of database' (or how exactly that is named) option for shrinking.

Then you may consider index defragmenting, helped us in similar circumstances.

0

If you've already shrunk your database, then give DBCC SHRINKDATABASE TRUNCATEONLY a try.

Reference.

Not the answer you're looking for? Browse other questions tagged or ask your own question.