Two ways to clear SQL Server log

Source: Internet
Author: User
Tags empty file size log
When the Server|sqlserver log file is full and the SQL database cannot write to the file, there are two methods available:
One way: Empty the log.
1. Open Query Analyzer, enter command
DUMP TRANSACTION database name with NO_LOG
2. Then open Enterprise Manager-right you want to compress the database-all tasks-shrink the database-shrink the file-Select the log file-in the shrink option to shrink to XXM, this gives you a minimum m number that you want to shrink to, just enter the number and make sure.

Another approach has a certain risk, because SQL Server log files are not immediately written to the database master file, such as improper handling, can result in loss of data.
1: Delete Log
Detach Database Enterprise Manager-> Server-> Database-> Right key-> Detach database
2: Delete log file
Additional database Enterprise Manager-> Server-> Database-> Right key-> attached database
This method generates a new log with a size of more than 500 K.

Note: The first method is recommended.

If you don't want it to get bigger later.
Use under SQL2000:
Right-click on the Database-> properties-> option-> failure recovery-model-select-Simple model.
or with SQL statements:
ALTER DATABASE name set recovery simple

In addition, Truncate log on checkpoint (this option is used in Sql7.0,sql 2000, the recovery model is selected as a simple model) when the checkpoint command is executed if the transaction log file exceeds its size of 70% Then clear its contents often set this option to true auto shrink periodically check the database when the unused space of the database file or log file exceeds 25% of its size, the system automatically shrinks the file so that its unused space equals 25% When the file size does not exceed its initial size when it is established, the file reduction file must also be greater than or equal to its initial size the reduction of the transaction log file can only be done if it is backed up or when the Truncate log on Checkpoint option is set to true.

Note: Generally established database default properties have been set, but encountered unexpected circumstances so that the database properties have been changed, please empty the log, check the database above properties, in case the transaction log again full.


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.