SQL Server: Shrink Database Log, Part II
Here is another approach to shrink an extensively large MS SQL Server log file:
Thanks to Stilgar for helping me out with this one.
Here is another approach to shrink an extensively large MS SQL Server log file:
Thanks to Stilgar for helping me out with this one.
In Microsoft SQL Server sometimes you can observe the LOG file growing uncontrollably and unexpectedly to a size times the size of the DATA file. I’ve witnessed a database with data file of 200 MB and a log file of 4 GB. Not only harddisk space is wasted, but the backup file becomes too inconvenient to drag around even heavily compressed.
Why does the LOG file grow that much is a different story, which I am not prepared to tell now. The question is how to make the LOG file small again within the “normal” boundaries. Using the “Shrink database” command does no good. Backup and restore of the database gives you the same old large log file.
The only solution I know so far involves the following steps:
Voila, the LOG file is back to normal.
Note that you might need to disable certain triggers and foreign keys before the copy operations - that depends completely on your database.