SQL Server database log full solution

Source: Internet
Author: User
Tags create index

Server Error in '/'application. </pre> <pre> -------------------------------------------------------------------------- </pre> <pre>
The log of the database tutorial 'databasename' is full. Back up the transaction logs of the database to release some log space.

If the above error occurs, change the fault recovery mode of the database to "simple" mode.

This problem mainly occurs on websites with large traffic volumes, and log files will increase rapidly.

Solve the problem that SQL database logs are full
1. Right-click database & rarr; attributes & rarr; options & rarr; fault recovery model & rarr; set to simple & rarr; OK;
2. Right-click database & rarr; all tasks & rarr; contract database & rarr; OK;
3. Right-click database & rarr; attribute & rarr; option & rarr; fault recovery model & rarr; set to large-capacity log record & rarr; OK.


1. Clear logs
Dump transaction database name WITH NO_LOG
2. Truncate transaction logs
Backup log database name WITH NO_LOG
3. Compress database files (if not compressed, the database files will not be reduced)
Enterprise Manager -- right-click the database you want to compress -- all tasks -- contract database -- contract file
-- Select Log File -- select to shrink to XXM in the contraction mode. Here, a minimum number of MB allowed to be shrunk is displayed. Enter this number directly and click OK.
-- Select data file -- select to shrink to XXM in the contraction mode. Here, a minimum number of MB allowed to be shrunk is displayed. Enter this number directly and click OK.
You can also use SQL statements to complete
-- Shrink database
Dbcc shrinkdatabase (customer profile)
-- Contract the specified data file. 1 indicates the file number. You can use this statement to query: select * from sysfiles dbcc shrinkfile (1)


In some cases, the transaction log may become very large, resulting in exhausted space or full. Generally, when the transaction log file occupies sufficient disk space and cannot be expanded, you will receive the following error message:
Error: 9002, Severity: 17, State: 2
The log file for database '%. * LS' is full.
In addition to this error message, SQL Server may mark the database as SUSPECT due to the lack of transaction log extended space. For more information about how to recover from this situation, see the "insufficient disk space" topic in SQL Server online help.

In addition, transaction log extensions may cause the following situations:
· Very large transaction log files.
· Transactions may fail and may start to roll back.
· Transactions may take a long time to complete.
· Performance problems may occur.
· Blocking may occur.

Cause
Transaction log extensions may occur for the following reasons or situations:
· Uncommitted transactions
· Very large transactions
· Operation: dbcc dbreindex and CREATE INDEX
· During restoration from transaction log backup
· Client applications do not process all results
· Query times out before the transaction Log is extended. You receive a false "Log Full" error message.
· Unreplicated transactions

Solution
When the log file is full and the SQL database cannot write the file, you can use either of the following methods:
One method: clear logs.
1. Open the query analyzer and enter the command
Dump transaction database name WITH NO_LOG
2. open the Enterprise Manager and right-click the database you want to compress -- all tasks -- shrink database -- shrink file -- select Log File -- select to shrink to XXM in the shrink mode, here we will provide a minimum number of M that can be reduced. Enter this number directly and click OK.

Related Article

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.