SQL Server 2008 Empty delete log file (instant log changes to several m)

Source: Internet
Author: User
Tags sql server query

SQL in the use of each query will generate a log, but if you do not go to clean up, maybe the whole hard are piled up oh, I encountered such a situation, the direct site backstage are not going. Let's learn how to clean this log.

SQL2008 Empty Delete log:

Method One:

 Use [Master]GOALTER DATABASEAfmsSETRECOVERY Simple withno_waitGOALTER DATABASEAfmsSETRECOVERY SimpleGO UseAFMSGODBCCShrinkfile (N'Afms_log', One, Truncateonly)GO Use [Master]GOALTER DATABASEAfmsSETRECOVERY Full  withno_waitGOALTER DATABASEAfmsSETRECOVERY FullGO

' Clearing the log in SQL2008 must be done in simple mode, and then back to full mode when the cleanup is complete.

 Use [Master]GOALTER DATABASEDnnameSETRECOVERY Simple withno_waitGOALTER DATABASEDnnameSETRECOVERY Simple--Simple ModeGO UseDnnameGODBCCShrinkfile (N'Dnname_log', One, Truncateonly)GO  'Here's Dnname_log if you don't know what the name is in sys.database_files, you can query it with the following annotated statement' UseDnname'GO'SELECT file_id, Namefrom sys.database_files;'gouse [master]goalter database Dnname set RECOVERY full with No_waitgoalter database Dnname SET RECOVERY Total--Revert to complete mode -Style Go

SQL2005 Empty Delete log:

Backup Log dnname with No_log ' Here's dnname is the name of the database you want to shrink, and I'm not going to comment anymore by changing the database name below. Godump transaction dnname with no_log gouse dnnamedbcc shrinkfile (2) Go

sqlserver2000 Compression Log

You can make the Jb51.ldf file very small, easy to back up the database, and so on, executed in SQL Server Query Analyzer.

1 DUMP TRANSACTION [jb51]  with  2BACKUPLOG[jb51] with   3DBCC shrinkdatabase ([jb51])

SQL Server 2008 Empty delete log file (instant log changes to several m)

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.