SQL Server log cleanup

Source: Internet
Author: User

Clearing the log in SQL Server must be done in simple mode, and then back to full mode when the purge action is complete.

*[databasename] The name of the database to compress the log.

Setting the database schema to Simple mode

ALTER DATABASE SET  with no_wait    ALTER DATABASE SET RECOVERY Simple

Querying log files for Filedid

SELECT *  from Sysfiles

Fill in the Filedid of the log with the first argument in parentheses in the following statement, where the second parameter refers to how many megabytes (M) the log is compressed

--Log will be compressed to 100M after execution

DBCC Shrinkfile (2,+)

Revert to Full mode

ALTER DATABASE SET  Full  with no_wait ALTER DATABASE SET  Full

Advantages: This cleanup log runs short of time, 90GB of log can be cleared in minutes or so, after the completion of a complete preparation-the part can be completed within minutes.

Cons: But this action is best not to be used frequently, as it will result in system fragmentation. Backup of log and diff in normal state--logs can be truncated.

SQL Server 2008 versions of the applicable statements

BACKUP LOG [DataBaseName]  with no_log DBCC Shrinkdatabase ([DataBaseName], truncateonly)

SQL Server log cleanup

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.