Monday, March 8, 2010

How to force a SQL database log file to shrink via SQL Manager UI

I’ve sometimes found that when trying to shrink a SharePoint SQL via the SQL Management interface, the database refuses to shrink, and in some cases even grows!

A colleague showed me an easy fix today which requires a simple (temporary) change to the database options.

Simply follow these steps (but bear in mind that you are following this advice at your own risk)

  1. Ensure you have a FULL backup of the database because you will be essentially "breaking" the full transaction log by carrying out this procedure.
  2. Right click the database and choose PROPERTIES, then click on Options
  3. Change the Recovery Model to ‘Simple
  4. Click OK
  5. Right click the DB, select Tasks > Shrink > Files
  6. Select ‘Log’ under file type
  7. Under shrink action, select ‘Reorganize pages…” and then set the new size to shrink the log down to
  8. Click OK and your database log file will be resized.
  9. Be sure to change the Recovery Model back to ‘FULL’ when completed’

No comments: