Friday, September 18, 2009

Remove large SQL 2005 Log file to save disk space

Sometimes we just do not need the big log file, specially if you are working on dev machine with SQL server - true in most cases with SharePoint 2007 server install. So here are the steps to clear some much needed space by removing the database log file. 
  1. Detach the database
  2. Rename the log file
  3. Attach the database without the log file
  4. Delete the log file
Let's say, the database name is WSS_Content. Open your SQL Server Management Studio,
Highlight the database -> Select Tasks , now select Detach and Click OK
Go to your log file folder -> rename the WSS_Content_log.ldf to be like testDev_log-to_be_deleted, and now go back to SQL Server Management Studio follow these steps -

Highlight Databases -> select Attach and click on Add -> add your database WSS_Content, highlight the log file and click the "Remove" button. This attach WSS_Content.mdf and create a new fresh log file.


After this is done, make sure that you verify the contents of the attached database and then delete your old log file.

And please don't forget to run Defrag on your machine, so that you can enjoy better performance.


Have Fun!!

No comments:

Post a Comment