How to reduce SQL Server log files (1/2)

Source: Internet
Author: User

How to reduce SQL Server log files
You can shrink the log file to the size you want. Copy the code to the Query Analyzer, and then modify the 3 parameters (database tutorial name, log file name, and target log file size) and run it (I've used it many times)

-----

 

Set NOCOUNT on

Declare @logicalfilename sysname,

@maxminutes int,

@new Size int

Use Marias-the database name to manipulate

Select @logicalfilename = ' Marias_log ',--log file name

@maxminu TES =--limit on time allowed to wrap log.

@newsize = 100-the size of the log file you want to set (m)

--Setup/initialize

Declare @originalsize int

Select @originalsize = Size

From Sysfiles

WHERE name = @logicalfilename

Select ' Original size of ' + db_name () + ' log is ' +

Convert (varchar, @originalsize) + ' 8k pages or ' +

Convert (varchar (@originalsize *8/1024)) + ' MB '

From Sysfiles

WHERE name = @logicalfilename

CREATE TABLE Dummytrans

(Dummycolumn char (8000) NOT NULL)

Declare @counter int,

@starttime datetime,

@trunclog varchar (255)

Home 1 2 last page
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.