Article ID: 873235 - Last Review: March 17, 2011 - Revision: 4.0 Recover from a full transaction log in a SQL Server database
On This PageINTRODUCTIONThis article describes the steps that you must follow when the transaction logs become too large. Full transaction logs can make your Microsoft SQL Server database unusable. This article describes how to truncate and shrink the transaction logs, and how to prevent the transaction logs from growing unexpectedly. MORE INFORMATIONReduce the transaction log sizeTo recover from a situation where the transaction logs are full, you must reduce the size of the transaction logs. To do this, you must truncate the inactive transactions in your transaction log and shrink the transaction log file.Note The transaction logs are very important to maintain the transactional integrity of the database. Therefore, you must not delete the transaction log files even after you make a backup of your database and the transaction logs. Truncate the inactive transactions in your transaction logWhen the transaction logs are full, you must immediately back up your transaction log file. While the backup of your transaction log files is created, SQL Server automatically truncates the inactive part of the transaction log. The inactive part of the transaction log file contains the completed transactions, and therefore, the transaction log file is no longer used by SQL Server during the recovery process. SQL Server reuses this truncated, inactive space in the transaction log instead of permitting the transaction log to continue to grow and to use more space.For additional information about the issues that you must consider when you make a backup of the transaction logs and the issues that you must consider when you restore the transaction log backups, visit the following topics in SQL Server Books Online:
Important After you manually truncate the transaction log files, you must create a full database backup before you create a transaction log backup. For additional information about the issues that may occur when you truncate the transaction log files, click the following article number to view the article in the Microsoft Knowledge Base: 62866
(http://support.microsoft.com/kb/62866/
)
Reasons why SQL transaction log is not being truncated
Shrink the transaction log fileThe backup operation or the Truncate method does not reduce the log file size. To reduce the size of the transaction log file, you must shrink the transaction log file. To shrink a transaction log file to the requested size and to remove the unused pages, you must use the DBCC SHRINKFILE operation. The DBCC SHRINKFILE Transact-SQL statement can only shrink the inactive part inside the log file.Note The DBCC SHRINKFILE Transact-SQL statement cannot truncate the log and shrink the used space inside the log file on its own. For more information about shrinking the transaction log files, see the following topics in SQL Server Books Online:
272318
(http://support.microsoft.com/kb/272318/
)
Shrinking the transaction log in SQL Server 2000 with DBCC SHRINKFILE
For additional information about the problems that may occur when you shrink the transaction log files, click the following article numbers to view the articles in the Microsoft Knowledge Base:
814574
(http://support.microsoft.com/kb/814574/
)
PRB: Error message: "Cannot shrink log file ..." occurs when you shrink the transaction log file
324432
(http://support.microsoft.com/kb/324432/
)
PRB: DBCC SHRINKFILE and SHRINKDATABASE commands may not work because of sparsely populated text, ntext, or image columns
Prevent the transaction log files from growing unexpectedlyTo prevent the transaction log files from growing unexpectedly, consider using one of the following methods:
More information about transaction log filesIn SQL Server 2000 and in SQL Server 2005, each database contains at least one data file and one transaction log file. SQL Server stores the data physically in the data file. The transaction log file stores the details of all the modifications that you perform on your SQL Server database and the details of the transactions that performed each modification. Because the transactional integrity is considered a fundamental and intrinsic characteristic of SQL Server, logging the details of the transactions cannot be turned off in SQL Server.The transaction log file is logically divided into smaller segments that are referred to as virtual log files. In SQL Server 2000, you can configure the transaction log file to expand as needed. The transaction log expansion can be governed by the user or can be configured to use all the available disk space. Any modifications that SQL Server makes to the size of the transaction log file, such as truncating the transaction log files or growing the transaction log files, are performed in units of virtual log files. If the transaction log file that corresponds to a SQL Server database is filled and if you have set the option for the transaction log files to grow automatically, the transaction log file grows in units of virtual log files. Sometimes, the transaction log file may become very large and you may run out of disk space. When a transaction log file grows until the log file uses all the available disk space and cannot expand any more, you can no longer perform any data modification operations on your database. Additionally, SQL Server may mark your database as suspect because of the lack of space for the transaction log expansion. For additional information about the scenarios that may cause the transaction log file to grow unexpectedly, click the following article number to view the article in the Microsoft Knowledge Base: 317375
(http://support.microsoft.com/kb/317375/
)
Transaction log grows unexpectedly or becomes full on SQL Server
REFERENCESFor additional information about troubleshooting the additional disk space requirement during the recovery process, see the "Insufficient disk space" topic in SQL Server Books Online. For additional information about the transaction log architecture, see the following topics in SQL Server Books Online:
APPLIES TO
| Other Resources Other Support Sites
CommunityGet Help NowArticle Translations
|





















Back to the top