Tuesday, September 26, 2006

Shrinking the Log File in SQL Server 2005

Sometimes we need to delete the log file as quickly as possible. This is not the best way but is the most simple. Only in 6 steps:
1 - Detach DataBase
2 - Rename Log file or remove if tou are completely sure.
3 - Attach the database. You have to select the mdf file of the database.
4 - If you have deleted or renamed the log file tou will see an error "Not found" in the log file of the attached database.
5 - Select the log file with the error and click on "Remove"
6 - Click on "OK"

Now you have the same database without the large log file. Automatically SQL Server creates another file with minimum size and you can delete the file.

Use this method only to shrink database files without imprtance (development or test DB).

4 Comments:

At 8:45 PM, Anonymous Anonymous said...

Very nice! I found a place where you can
make some nice extra cash secret shopping. Just go to the site below
to see what's available in your area.
I made over $900 last month having fun!
make extra money

 
At 10:52 PM, Anonymous Anonymous said...

it doesn't work. sql will not reattach the mdf (data file) without the corresponding ldf (log file).

 
At 8:33 PM, Blogger Àlex said...

Have you tried it? If you remove the file (step 5), SQL Server will create a new log file with the default size (2MB).

Obviously, you will lose the information in the log file. For that reason this menthod is only applicable in a development environment.

 
At 6:16 AM, Anonymous cialis said...

Hi, well be sensible, well-all described

 

Post a Comment

<< Home