Clear logs for each version of the SQL database

Source: Internet
Author: User

SQL2005 Empty Delete log:

Copy CodeThe code is as follows: Backup Log dnname with no_log--' Here's dnname is the name of the database you want to shrink, and notice to modify the database name below, I will no longer comment. Go DUMP transaction dnname with no_log go use Dnname DBCC shrinkfile (2) Go

SQL2008 Empty Delete log:

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

Copy CodeThe code is as follows: Use [master] GO ALTER database dnname SET RECOVERY simple with no_wait GO ALTER DATABASE dnname SET RECOVERY Simple- -Simple mode go use dnname go DBCC shrinkfile (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

' Use Dnname

' GO

' SELECT file_id, Namefrom sys.database_files;

' Go use [master] GO ALTER DATABASE dnname SET RECOVERY full with no_wait GO ALTER DATABASE dnname SET RECOVERY full--Restore to end Full Mode 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.

Copy CodeThe code is as follows: DUMP TRANSACTION [jb51] with no_log
BACKUP LOG [jb51] with no_log DBCC shrinkdatabase ([jb51])

Clear logs for each version of the SQL database

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.