SQL Server 2008 Shrink log Empty Delete large log file

Source: Internet
Author: User

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

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.