15

In Microsoft SQL Server 2005, is it OK to shrink the log file of an online database, or will it cause an interruption of service?

3 Answers 3

7

Shrinkfile will not take your database offline.

13

DBCC SHRINKFILE itself does not make the database go offline. However, simply executing this command will not necessarily reduce the size on disk of the log, which depends on when the last full (for SIMPLE recovery types) or t-log (for FULL recovery type) backup was taken. If there's not been a recent backup of the logs then there'll be no log space to reclaim.

Finally, unless there has been some unforeseen, explosive growth due to an abnormally large write operation/batch, you may want to reconsider shrinking the file because the database is showing a need for a log file that large and the server needs to dedicate resources to expanding it back out. Perhaps adding storage would be a reasonable alternative.

0
7

Yes, it's fine. It doesn't affect any existing transactions, nor does it move any data around like database shrinking. Don't shrink it right back though, because growing a log file takes effort.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.