SQLServer clear deletion logs

Source: Internet
Author: User
Tags sql server query
Logs are generated for each query in SQL, but if you do not clean up for a long time, the whole hardware may be full. In this case, I cannot directly enter the website background. Next let's take a look at how to clear this log SQL2005 clear the delete log: copy the Code as follows: BackupLogDNNamewithno_log

Logs are generated for each query in SQL, but if you do not clean up for a long time, the whole hardware may be full. In this case, I cannot directly enter the website background. Next, let's take a look at how to clear this Log. SQL2005 clears the delete Log: the code is as follows: Backup Log DNName with no_log'

Logs are generated for each query in SQL, but if you do not clean up for a long time, the whole hardware may be full. In this case, I cannot directly enter the website background. Next, let's take a look at how to clear this log.

SQL2005 clear deletion logs:

The Code is as follows:

Backup Log DNName with no_log the DNName here is the name of the database you want to contract. You must modify the following database name and I will not comment it out.

Go

Dump transaction DNName with no_log

Go

USE DNName

Dbcc shrinkfile (2)

Go

SQL2008 clear deletion logs:

'Log cleanup in SQL2008 must be performed in simple mode. After the cleanup is completed, the system calls back to full mode.

The 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', 11, TRUNCATEONLY)

GO

'Dnname_log here, if you do not know the name in sys. database_files, you can use the following annotated statement to query

'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 FULL Mode

GO

Sqlserver2000 compressed logs

The jb51.ldf file can be very small to facilitate database backup, and can be executed in the SQL Server Query analyzer.

The Code is as follows:

Dump transaction [jb51] WITH NO_LOG

Backup log [jb51] WITH NO_LOG

Dbcc shrinkdatabase ()

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.