SQL2008 's Shrink log
Because SQL2008 is optimized for file and log management, the following statements can be run in SQL2005 but have been canceled in SQL2008:
(SQL2005)
Backuplog Dnname with No_log
Go
Dumptransaction Dnname with No_log
Go
Use Dnname
DBCC Shrinkfile (2)
Go
--------------------------------------------------------------
(SQL2008):
Clearing the log in SQL2008 must be done in simple mode, and then back to full mode when the purge is complete.
Scenario One: Full command mode
Use[master]
go
ALTERDATABASE Dnname set recovery simple with no_wait
go
alterdatabase dnname set recovery simple --Simple Mode
go
use dnname
go
dbcc shrinkfile (N ' Dnname_log ' , 11, truncateonly)
go
use[master]
go
ALTERDATABASE Dnname set recovery fullwith no_wait
go
alterdatabase dnname set recovery full --revert to Full mode
go
Scenario Two: Partial command mode + task-shrink-file (single database)
Alterdatabase dnname SET RECOVERY Simple--Easy mode
GO
Right-task-shrink-file-Make sure the log for the database is only 1M
Alterdatabase dnname SET RECOVERY Full--revert to fully mode
GO
Advantages: This cleanup log runs short of time, 90GB of log can be cleared in minutes or so, after doing a full backup in minutes
can be completed.
Cons: But this action is best not to be used frequently, as it will result in system fragmentation. Log and diff backups can be truncated in normal state.
The appropriate environment for this statement is used when the system's log file abnormally increases or the backup log time is too long to affect production.
SQL Server 2008 Shrink log Empty Delete large log file