Reduce SQL statements for SQL Server log files

xiaoxiao2021-03-06  14

Paste the following code to the SQL Query Analyzer (Note Modify the 3 parameters of the red part):

Set NoCount Ondeclare @LogicalFileName Sysname, @ Maxminutes Int, @ Newsize Int

Use Dicky - Recruitment Database Name Select @LogicalFileName = 'Dicky_Log', - Logistic Name of Log File, Non-physical File Name @maxMinutes = 10, - Limit On Time Allowed to Wrap Log. @ Newsize = 2 - - Need to reset the size of the log file (unit: m), this value must be less than the original file size

- 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) 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-50654.html

New Post(0)