What is the method and code of log compression in MS SQL SERVER database
MS SQL SERVER database log compression method and code, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
MSSQL performance is very good, but after the database has been used for a period of time, the database becomes very large, the actual amount of data is not large. It is usually caused by the database log! Database logs can grow by hundreds of megabytes. The MSSQL virtual host on the Internet is also expensive, so if you want to prevent the database from overcapacity, you have to compress the database log or delete the database log.
Next, I'd like to introduce you to a method.
1. Open Enterprise Manager
2. Open the database to be processed
3. Click menu > tools > SQL query Analyzer
4. Type in the input window:
The code is as follows:
DUMPTRANSACTION [database name]
WITHNO_LOG BACKUPLOG [database name]
WITHNO_LOG DBCCSHRINKDATABASE ([database name])
Click execute! In this way, the database operation is successful.
The methods in the program:
Compress database log
-1. Clear the log exec ('DUMPTRANSACTION [' + @ dbname+'] WITHNO_LOG')
-- 2. Truncate transaction log: exec ('BACKUPLOG [' + @ dbname+'] WITHNO_LOG')
-3. Shrink database files (if not compressed, database files will not reduce exec ('DBCCSHRINKDATABASE ([' + @ dbname+'])')
After reading the above, have you mastered the MS SQL SERVER database log compression method and code method? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!