Delete SQL Server logs

Source: Internet
Author: User

When a database is used, it will increase log files, degrade database performance, and occupy a large amount of disk space. All SQL Server databases have log files, which record users' operations on Database modifications. You can clear database logs by directly deleting log files and clearing logs.

1. delete a LOG

1. Separate the database. Before you detach a database, make sure that you back up the database. Select database -- Right-click -- task -- detach.

Select Delete Connection

After the database is detached, the database that has been detached is invisible to the Database List.

2. Delete LOG files

3. When attaching a database, the system will remind you that the log file cannot be found.

Delete the ldf file of the database information:

After attaching the database, a new log file log will be generated, which is 504 K of the new log file.

You can also run the following command to complete the preceding operations:

use master;
exec sp_detach_db @dbname='TestDB';
exec sp_attach_single_file_db @dbname='TestDB',@physname='D:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008\MSSQL\DATA\TestDB.mdf'
  

 

 

 

 

 

 

IIClear logs

This command is supported in SQL Server 2005 and 2000. SQL Server 2008 does not support this command.

DUMP TRANSACTION TestDB WITH NO_LOG

 

Iii. shrinking database files

DBCC SHRINKFILE ('TestDB_log',1) 

 

 

4. truncate transaction logs

BACKUP LOG TestDB WITH NO_LOG

 

This command is not supported in SQL Server 2008 and can be used in SQL Server 2005 and 2000.

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.