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.