MS SQL Server View repository size and compression log file

Source: Internet
Author: User

The company has to standardize the size of the personnel library every month.

The following is a SQL Server with the size of the SQL repository:

SELECT    db_name(database_id) as [Database Name],    [Name]  as [Logical Name], ((Size* 8)/ 1024x768) as [Size (MB)],--the original unit of size is bit, so multiply 8 to byte and multiply by 1024 to MByte.     [Differential_base_time]  as [differential Base time] fromsys.master_filesWHERE db_name(database_id)inch('SMOOTHHR','Hrreport','Smoothexchage');--' smoothhr ', ' hrreport ', ' smoothexchage ' are divided by the name of the repository. 

Results:

You can see that the smoothhr_log is larger and can be compressed.

The compression log file needs to be in a simple mode, so you can take a look at the library's journal-ready mode:

SELECT  from WHERE inch ('smoothhr','hrreport','smoothexchage  ');

You can see all the "full" mode, so turn it into a simple mode, then log compression, and then restore the full-copy mode:

 UseSMOOTHHRGOALTER DATABASESmoothhrSETRECOVERY Simple--if it is full (fully provisioned) mode, set the simple recovery modeGODBCCShrinkfile (Smoothhr_log,Ten)--compressing log files to 10MGOALTER DATABASESmoothhrSETRECOVERY Full--back to the original full (fully prepared) mode after completionGO

See the following results, said success!

At this time, the size of the DB, the log file is successfully compressed:

MS SQL Server View repository size and compression log file

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.