Use the query analyzer to clear logs and reduce log files

Source: Internet
Author: User
Method 1,
In the current database, select fileid, groupid, name from sysfiles where groupid = 0 then. The following results are obtained: fileid groupid name 2 0 test_log and above. fileid is the log file ID and name is test_log.

-- In the query analyzer, select the database for which logs are to be cleared and execute the following SQL
Backup log database name with no_log
DBCC shrinkfile (Log File Name or log file ID, the target size to be reduced)
For example:
Backup log test with no_log
DBCC shrinkfile (2, 2)
Or
Backup log test with no_log

   DBCC  SHRINKFILE   ('test_log',10)   
If you do not want it to become larger, right-click the database and choose Properties> Options> fault recovery modelSimple ModelThat's it! Or use SQL statement alter database name set recovery simple method 2, SQL Server Enterprise Manager-> SQL Server group-> server-> database-select database entity-right-click-> All task-separate database, then, delete it in the physical path of the database. LDF file, right-click the database, and append all tasks to the database. Then, the log file is generated again.

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.