How to narrow the SQL Server log file

zhaozj2021-02-12  194

Turn the code COPY to the query analyzer, then modify the three parameters (the database name, log file name, and the size of the target log file), run.

----- set nocount ondeclare @logicalfilename sysname, @ maxminutes int, @ newsize int

Use Marias - Database name to be operated SELECT @LogicalFileName = 'Marias_log', - log file name @MaxMinutes = 10, - limit on time allowed to wrap log. @ Newsize = 100 - You want to set the log file you want to set Size (m)

- Setup / initializeDECLARE @OriginalSize intSELECT @OriginalSize = size FROM sysfilesWHERE name = @LogicalFileNameSELECT 'Original Size of' db_name () 'LOG is' CONVERT (VARCHAR (30), @ OriginalSize) '8K pages or' Convert (VARCHAR (30), (@ OriginalSize * 8/1024)) 'mb'From sysfileswhere name = @LogicalFileNamecreate Table DummyTrans (DummyColumn Char (8000) Not null

Declare @counter int, @ starttime datetime, @ trunclog varchar (255) select @starttime = getdate (), @ Trunclog = 'backup log' db_name () 'with truncate_only'

转载请注明原文地址:https://www.9cbs.com/read-6692.html

New Post(0)