Dbcc shrinkdatabasems SQL database log Compression Method

Source: Internet
Author: User

Ms SQL database log Compression Method
Ms SQL performance is very good, but the database has been used for a period of time, the database has become very large, the actual amount of data is not large. It is generally caused by database logs! The growth of database logs can reach several hundred MB.

The cost of MSSQL virtual hosts on the Internet is also high. To avoid database overuse, You Have To Compress database logs or delete database logs.
Next, I will introduce a method.

1. Open the Enterprise Manager
2. Open the database to be processed
3. Choose tools> SQL query analyzer.
4. In the input window, enter:

Dump transaction [database name] WITH NO_LOG
Backup log [database name] WITH NO_LOG
Dbcc shrinkdatabase ([database name])
Click to execute! In this way, the database operation is successful.

Methods In the program:
Compressing database logs
-- 1. Clear logs
Exec ('dump TRANSACTION ['@ dbname'] WITH NO_LOG ')
-- 2. truncate transaction logs:
Exec ('backup LOG ['@ dbname'] WITH NO_LOG ')
-- 3. compress the database file (if it is not compressed, the database file will not be reduced
Exec ('dbcc SHRINKDATABASE (['@ dbname'])')



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.