SQL Server : Reclaim your unused table space
Posted by
Venkat Varkala
Labels:
SQL Server
I have a website, and its database has grown to 8 Gigs but my hosting contract supports only 4 gigs. This has become such a big problem. I deleted 6 months of data but still the database was 7 gigs. I cannot afford to buy that kind of database space thought of taking my website down but luckily I was able to figure out how to reclaim usnused space in database. Getting the database size by tables really helped me understand how my data is distributed among tables.
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"
Above command gives database size by table and also shows you the unused table space. DBCC CLEANTABLE can be used to clean up the unused space in a table, though this cleaned up my unused table space but it still didn't decrease the database size tries shriking database and file but no luck. ALTER INDEX can be used to rebuild the Indexes, when I rebuilt the indexes the database size decreased to 3.8 gigs... never knew indexes will take up so much space. http://www.mssqlcity.com/Articles/Undoc/SQL2000UndocSP.htm has good list of SQL 2000 undocumented stored procedures.
Subscribe to:
Post Comments (Atom)

Post a Comment