SQL Server2008 Cleanup log method. sql

Source: Internet
Author: User

Recently the customer reflected a problem, saying that the application server failed to write the database, the first thought is the application server problem, and later from the feedback database running log, because the database is full of things log, resulting in no longer write data.

The following conclusions are drawn from this problem:

1, the database data files and things log files do not automatically expand by percentage, but should be increased by MB. Like every time you grow 100MB~200MB

2, to regularly clean up the database of things log files

3, in the event of database related problems, should be the first time to check the database running log

Here's how SQL Server 2008 cleans up the things log, and it's recommended to make it a timed job without having to intervene manually every time.

Use [master]
GO
ALTER DATABASE [databasename] SET RECOVERY simple with no_wait
GO
ALTER DATABASE [databasename] SET RECOVERY Simple
GO
Use [DatabaseName]
GO
DBCC shrinkfile (N ' Databasename_log ', 10,truncateonly)
GO
Use [master]
Go
ALTER DATABASE [databasename] SET RECOVERY full with no_wait
GO
ALTER DATABASE [databasename] SET RECOVERY full
GO

SQL Server2008 Cleanup log method. sql

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.