Get the App
SLTechnology News&Howtos  ›  Database  › 

How to empty log files in SQL Server 2008

Shulou Source: shulou.com Published: 2022-05-31 22:26:34 11月15日 Update

Today, I will talk to you about how to clear log files in SQL Server 2008. Many people may not know much about it. In order to let everyone know more, Xiaobian summarizes the following contents for everyone. I hope everyone can gain something according to this article.

SQL2008 Empty Delete Log:

Method 1:

USE [master]GOALTER DATABASE AFMS SET RECOVERY SIMPLE WITH NO_WAITGOALTER DATABASE AFMS SET RECOVERY SIMPLEGOUSE AFMSGODBCC SHRINKFILE (N'AFMS_Log' , 11, TRUNCATEONLY) GOUSE [master]GOALTER DATABASE AFMS SET RECOVERY FULL WITH NO_WAITGOALTER DATABASE AFMS SET RECOVERY FULLGO

In SQL2008, log cleanup must be performed in simple mode, and then reverted to full mode after the cleanup action is completed.

USE [master]GOALTER DATABASE DNName SET RECOVERY SIMPLE WITH NO_WAITGOALTER DATABASE DNName SET RECOVERY SIMPLE --SIMPLE SINGLE MODULAR GOUSE DNNameGODBCC SHRINKFILE (N'DNName_Log', 11, TRUNCATONLY) GO ' DNName_Log here If you don't know what the name is in sys.database_files, you can query it with the following commented statement 'USE DNName 'GO 'SELECT file_id, nameFROM sys.database_files;'GOUSE [master]GOALTER DATABASE DNName SET RECOVERY FULL WITH NO_WAITGOALTER DATABASE DNName SET RECOVERY FULL --revert to full mode GO

SQL2005 Clears Delete Log:

Backup Log DNName with no_log 'DNName here is the name of the database you want to shrink, pay attention to modify the database name below, I will not comment anymore. godump transaction DNName with no_log goUSE DNNameDBCC SHRINKFILE (2)Go

sqlserver2000 compressed logs

You can make the jb51.ldf file very small to facilitate backup of databases, etc., and execute it in sqlserver query analyzer.

DUMP TRANSACTION [jb51] WITH NO_LOG BACKUP LOG [jb51] WITH NO_LOG DBCC SHRINKDATABASE([jb51]) Having read the above, do you know more about how to empty log files in SQL Server 2008? If you still want to know more knowledge or related content, please pay attention to the industry information channel, thank you for your support.

Tags: Logs schemas files content data databases comments queries analyzers actions names backups methods more for knowledge articles industries statements information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Apple NVidia OPPO Reno Shulou Tech Info