Script used to shrink, SQL 2008
--Getting below error---
Script failed:Cannot shrink log file 2 (DirectoryLog) because the logical log file located at the end of the file is in use.
The quick answer is that the transaction log is made up of multiple smaller virtual log files (VLFs) and that transaction log usage is circular. This means that you would be unable to shrink the file because the latest VLF is in use. I'd recommend running a transaction and then performing a checkpoint to hopefully go to the next VLF.
For a proper and full explanation please read [Paul Randal's post on the matter]
Of interest, why are you shrinking the transaction log on this system? By switching recovery models you are losing your point in time recovery capability which may severely impact your recovery point objectives. Also, your transaction log will grow again. You should be taking regular transaction log backups to properly manage growth.: http://www.sqlskills.com/BLOGS/PAUL/post/Inside-the-Storage-Engine-More-on-the-circular-nature-of-the-log.aspx
answered Feb 08, 2012 at 09:29 PM
+1 to @SirSQL.
And I only add, if you ara swithing the recovery model to simple and than back into full, than it probably means, that you do not need the point in time recovery and then you can keep the the Simple recovery mode.In case you really need the point in time recovery and FULL recovery mode, then schedule a periodic LOG backups. In case you have log backups scheduled, than probably the intarval between backups is too long and your log grows too much. Then you should shorten the intervals between log backups.
answered Feb 09, 2012 at 11:00 AM