title: Cannot free up unallocated space in SQL Server 2005
body: <p>I have a very large database (40 gig) and have run the procedure </p>
  
  <pre><code>sp_space_used 
  </code></pre>
  
  <p>and found that there is 10 gig of unallocated space.  Obviously this is a lot and the .mdf file is taking up most of the disk. I have looked into running </p>
  
  <pre><code>DBCC SHRINKDATABASE (db, TRUNCATEONLY);
  </code></pre>
  
  <p>Do I also need to shrink the transaction log or will shrinkdatabase take care of this?  What are the negative implications of running this procedure?  Can I run this while the database is in use? I've tried running the shrinkdatabase command but still have lots of unallocated space.</p>
  
  <pre><code>database_size   unallocated space
  49575.06 MB   8393.49 MB
  
  reserved       data        index_size   unused
  42170328 KB 22704672 KB 19099160 KB  366496 KB
  </code></pre>
  
  <p>NOTE: the database has a simple recovery model so I'm guessing I don't need to backup the log at all.</p>
  
  <p>What is the difference between running </p>
  
  <pre><code>DBCC SHRINKFILE (datafile, TRUNCATEONLY)
  </code></pre>
  
  <p>to</p>
  
  <pre><code>DBCC SHRINKDATABSE (db, TRUNCATEONLY)?
  </code></pre>