SQL Server 2005 and 2008 clear log method

SQL2008 shrink log 
Because SQL2008 optimizes file and log management, the following statement can be run in SQL2005 but has been canceled in SQL2008:
SQL2005 method of clearing the log:
Backup Log DNName with no_log
go
dump transaction DNName with no_log
go
USE DNName 
DBCC SHRINKFILE (2)
Go
------------------------------------------- -------------------
The method
of clearing the log in SQL2008 : In SQL2008, clearing the log must be performed in simple mode, and then transferred back to full mode after the clearing action is completed.
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
    USE [master]
    GO

    the ALTER DATABASE DNName the SET NO_WAIT the RECOVERY the WITH FULL

    GO

    the ALTER DATABASE DNName the SET the RECOVERY FULL - revert to full mode

    GO

advantages: short run this Clear logs time spent, 90GB of log can be cleared is completed in about minutes after the finish to do A full backup
can be completed in minutes .
Disadvantages: However, it is best not to use this action often, because its operation will bring about system fragmentation. Under normal conditions, the backup of LOG and DIFF can truncate the log.
The appropriate environment for this statement: when the system log file is abnormally increased or the backup LOG time is too long, which may affect production.

Guess you like

Origin www.cnblogs.com/dcrenl/p/12705268.html