SQL Server Delete Log

Source: Internet
Author: User
Tags microsoft sql server

1 in the process of using the database will increase the log files, so that the performance of the database decreased, and occupy a large amount of disk space. The SQL Server database has a log file, and the log file records the user's actions on the database modifications. You can clear the database log by directly deleting the log file and emptying the logs.

First, delete log

1, separate the database. Before separating the database, make sure to do a full backup of the database, select the database-right--task--separate.

Tick Delete connection

The detached database will not be visible to the database list after it is detached.

2. Delete log file

3, attach the database, the additional time will be reminded to find the log file.

Remove the LDF file for database information information:

After attaching the database, a new log file is generated and the new log file size is 504K.

You can also do this by command:

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 '

Second , empty the log

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

DUMP TRANSACTION TestDB with no_log

iii. shrinking database files

Iv. truncation of transaction logs

BACKUP LOG TestDB with no_log

The command is also not supported in SQL Server 2008, which can be used in SQL Server 2005 and 2000.

SQL Server Delete Log

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.