How to Reduce Log File Size in SQL Server

Source: Internet
Author: User

First
Use [database name];
Exec sp_helpfile;

You can use sp_helpfile to query the logic name of the log file, and then you can use DBCC to reduce the LOG file
Backup log [database name] WITH TRUNCATE_ONLY
Dbcc shrinkfile ([logical name of log file], 1)

This method is no longer applicable in ms SQL Server 2008 and ms SQL Server 2008 R2, and the prompt is: TRUNCATE_ONLY is not a valid BACKUP option.

This operation method should be adopted:

Copy codeThe Code is as follows:
-- First, change the database recovery mode to Simple.
Alter database [DATABASE name] set recovery simple;
GO
-- Reduce the log file to 1 M. The logical name can be obtained through sp_helpfile.
Dbcc shrinkfile ([log File logical name], 1 );
GO
-- Reset the recovery mode of the database
Alter database [DATABASE name] set recovery full;
GO

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.