Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 trying to shrink the '.mdf' file

Author  Topic 

rabbott
Starting Member

2 Posts

Posted - 2007-06-04 : 15:47:36
Hello,

I have a database that the '.mdf' file is just huge. The physical size on disk is approximately 110 gig. I run weekly maintenance plans to rebuild the indexes on it.

I ran the 'sp_spaceused' command and got the following results:

database size: 106996.25 MB
unallocated space: 9614.35 MB
reserved: 99716504 KB
data: 13968056 KB
index_size 4002184 KB
unused: 81746264 KB

I was trying to clear the unused space, the numbers are telling me that I have 81 gig of space unused, but no matter what I do the '.mdf' file will not shrink.

I ran the following command: DBCC SHRINKDATABASE ({dbname}, 10,TRUNCATEONLY)

Any thoughts?

Thanks for the help

Richard

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-06-04 : 16:26:26
Take a look at this script:
Shrink DB File by Increment to Target Free Space
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=80355

CODO ERGO SUM
Go to Top of Page

rabbott
Starting Member

2 Posts

Posted - 2007-06-04 : 16:49:38
Thanks for the script Michael. I'll give it a try.

One thing that I'm also trying to figure out is how the database '.mdf' got so big in the first place. In our database we flag records as being deleted - we don't actually run a 'delete' statements on them - very few tables ever get dropped so I'm just wondering if the weekly reindexing maintenance plan is causing the file to get bloated?
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-06-04 : 17:06:58
Make sure your run the command this way so that you are getting a correct result:
exec sp_spaceused @updateusage = 'true'

You can use this script to look at the size of individual tables:
Script to analyze table space usage
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61762




CODO ERGO SUM
Go to Top of Page
   

- Advertisement -