SqlServer clear logs and shrink Databases

Source: Internet
Author: User
A large number of log files are generated during the use of SQL Server databases, especially frequently updated systems. Due to the commercial operation, our databases are backed up. After a while, we can clear the log data. Because most of the time we use virtual hosts, the Space Provider imposes restrictions on the security policy and directs

A large number of log files are generated during the use of SQL Server databases, especially frequently updated systems. Due to the commercial operation, our databases are backed up. After a while, we can clear the log data. Because most of the time we use virtual hosts, the Space Provider imposes restrictions on the security policy and directs

A large number of log files are generated during the use of SQL Server databases, especially frequently updated systems.

Due to the commercial operation, our databases are backed up. After a while, we can clear the log data. Because we are currently using virtual hosts many times, the Space Provider imposes security policy restrictions, resulting in no way to clear our database logs.

The only way is to use the dbower permission to open the query analyzer and use the following SQL statement to clear and contract your database space:

1. Clear logs
Dump transaction [yourdbname] WITH NO_LOG;
2. truncate database logs
Backup log [yourdbname] WITH NO_LOG;
3. shrink the database
Dbcc shrinkdatabase ([yourdbname]);

PS: the order of the preceding SQL statements cannot be disrupted.

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.