The transaction log for the database is full. To find out why the space in the log cannot be reused __ database

Source: Internet
Author: User
Tags microsoft sql server
Generally do not recommend to do 4th, 62 steps
4th step is unsafe, it is possible to corrupt the database or lose data
6th step if the log reaches the upper limit, subsequent database processing will fail, and the log will not be restored until it is cleaned.


1. Empty log
DUMP TRANSACTION Library name with NO_LOG
2. Truncate the transaction log:
BACKUP LOG Library name with NO_LOG
3. Shrink the database file (if not compressed, database files do not reduce Enterprise Manager--right--the database you want to compress--all tasks--shrink the database------------------------------------------- Enter this number directly, OK--Select the data file--in the contraction way to choose to shrink to XXM, here will give a allow to shrink to the minimum m number, directly enter this number, OK, or SQL statement to complete
--Shrinking the database DBCC shrinkdatabase (library name)
--Shrink the specified data file, 1 is the file number, you can query through this statement: SELECT * from Sysfiles DBCC shrinkfile (1)


4. In order to maximize the reduction of log files (if it is SQL 7.0, this step can only be done in Query Analyzer)
A. Detaching a database: Enterprise Manager--server--database--right key--detach database B. Delete log files on my Computer C. Additional databases: Enterprise Manager--server--database--right--Append database This method will generate a new log with a size of more than 500 K or in code: The following example separates pubs and attaches a file in pubs to the current server.
A. Separating EXEC sp_detach_db @dbname = ' Library name '
B. Delete log file C. additional EXEC sp_attach_single_file_db @dbname = ' Library name ', @physname = ' c:\rogram Files\Microsoft SQL Server\mssqldata\ Library Name. mdf '


5. In order to be able to automatically shrink later, do the following settings: Enterprise Manager--server-right key database-Properties--Options--Select Auto Shrink
--sql statement setting: EXEC sp_dboption ' library name ', ' autoshrink ', ' TRUE '

6. If you want to not let it grow too big Enterprise Manager-server-right Key database-attribute-transaction log-limit file growth to XM (x is the maximum data file size you allow)
How the--sql statement is set: ALTER DATABASE name modify file (name= logical file name, maxsize=20)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.