Monday, March 12, 2012

mgmnt studio express won't shrink .ldf files

I'm attempting to truncate/shrink a db (mdf & ldf) to be able to zip it and email it. From Object Explorer I select the db->tasks->shrink->files->filetype->log->release unused spage or reorganize->shrink file to (0mb). This action does not change the size of the .ldf file. Shrinking the mdf works just like SQL 2000 - as expected. Why don't the actions taken do what they imply for the .ldf file? If this is not what the selections mean, what do they mean?

thanks, jack

If you want the LDF to skrink to 0mb then you need to truncate the log because SQL Server in shrink mode reserves what was active log now called virtual log before releasing space to the OS. You can run DBCC Shrinkfile and see what error you get because 2005 now logs the error in the error log. Run a search for DBCC Shrinkfile and Truncate log in the BOL. Hope this helps.

|||Caddre, your response led me to information that explains the 'reality' of dealing with the logfile. In my case since I 'want' an empty db to distribute,I found that I could just detach the db, then delete the .ldf file. When I re-attach a 'new' empty log file is created. -- thanks, jack

No comments:

Post a Comment