I have been doing database administration and have been asked several times to reduce the size of database files. The actual mdf file is small, 3MB, but the LDF file is 10GB !!
I have read about the DBCC SHRINKFILE command and tried this, but the file has stayed at 10GB even though it said the command executed fine.
I've also tried using the wizard in SQL Server to reduce the LDF to a specified file size (800MB), this also failed to change the size even though it gave me the impression it had worked and was successful via the wizard.
The best thing I found is to change the recovery mode of database to RECOVERY SIMPLE before executing the SHRINKFILE command. After that change back the recovery mode to FULL.
ALTER DATABASE ExampleDB SET RECOVERY SIMPLE DBCC SHRINKFILE('ExampleDB_log', 0, TRUNCATEONLY) ALTER DATABASE ExampleDB SET RECOVERY FULL
Happy Coding :)
Comments
Post a Comment