SQL Server 2008 Purge logs

Source: Internet
Author: User

Running SQL Server commands in Windows requires the use of SQLCMD commands, which are installed when you install SQL Server.

Use SQLCMD to enter interactive mode:

The previously used commands are:

DatabaseName With no_log  databasename with no_log        --Truncate transaction log DBCC SHRINKDATABASE (databasename)          -- Shrinking a Database

  

These commands need to be executed sequentially and are often much faster than using the "shrink" command directly in the right-click menu.

However, this command does not work under the 2008 version and is limited to sql2005~

SQL2008 is optimized for file and log management by using the following command: Clear the log in simple mode, and then revert back to full mode when the purge action is complete

DatabaseName DatabaseName SET RECOVERY Simple   databasename godbcc shrinkfile (N 'databasename_log ', one, truncateonly) GO

Revert to Full mode

DatabaseName DatabaseName SET RECOVERY  Full--revert to complete mode go

  

SQL Server 2008 Purge logs

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.