I have been receiving following question again and again either through email or through comments on this blog. It is always the same log full problem, and the answer is short.

My log file is too big, what should I do?
Answer to this question is in three steps.
- Backup the log file to any device.
- Truncate the log file.
- Shrink the log file.
I have previously written two article about this issue. Refer them for additional information and details.
SQL SERVER – Shrinking Truncate Log File – Log Full(Script)
SQL SERVER – Shrinking Truncate Log File – Log Full – Part 2(Management Studio)
Why the Log Full Problem Keeps Coming Back
Backup, truncate and shrink will get you out of trouble today, but if you stop there, the file grows again next week. The real question is why the log is not being reused. SQL Server tells you directly. Run SELECT name, recovery_model_desc, log_reuse_wait_desc FROM sys.databases and look at the last column for your database.
The most common answer I see is LOG_BACKUP. It means the database is in the full recovery model and nobody is taking log backups. In full recovery, the log keeps every change until a log backup copies it out. The fix is not a bigger disk. Pick one of these:
- If you need point in time restore, schedule regular log backups, at an interval that matches how much data you can afford to lose.
- If you do not need point in time restore, switch the database to the simple recovery model. The inactive part of the log is then reused after each checkpoint.
Two more notes. On SQL Server 2008 and later, the old BACKUP LOG ... WITH TRUNCATE_ONLY option no longer exists, so a real log backup or the simple recovery model are your choices. And shrink the file only once, to a sensible size, not every night. A log that is shrunk and grows again over and over wastes time, and it can end up with too many virtual log files, which slows down startup and restore. Once the cause is fixed, keep an eye on the log size for a week to make sure it stays flat.
Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.





5 Comments. Leave new
How to shrink the database not the the log file
Best regards
Sayed
Saudi Arabia
Hi My Database log file is large so finding a data from database it is very slow the result of output getting.
so what i should do?
And second problem is whenever multiple user upload data on that server that time web site is not running i.e. error is generate server unavailable application.so what is the reason…?
how can we backup one datafile and restore it in another server ?
is it possible?
To MohammadReza:
Yes it is possible, just restore it as you would in any normal database. Just make sure you do have a database to restore it to.
Hi,
Can you please suggest me on the below.
I want to set up the notification whenever my t-log is full.
can we use a script for automatically shrinking the log file.