Trunkera transaktions loggar i MSSQL 2000

By support at april 14, 2008 17:58
Filed Under:

Då de blivit för stora kan följande användas.. har ingen aning varför inte detta fungerar automatiskt på denna servern.

Declare @logfile_id int
Backup Log <databas> with No_Log
Select @logfile_id = max(fileid) from dbo.sysfiles where name like '%log%'
DBCC Shrinkfile (@logfile_id, truncateonly)
Go

 

Gå igenom hela servern med

   1: declare @ssql nvarchar(4000)
   2: set @ssql= '
   3:         if ''?'' not in (''tempdb'',''master'',''model'',''msdb'') begin
   4:         use [?]
   5:     Declare @logfile_id int
   6:     Backup Log ? with No_Log
   7:     Select @logfile_id = max(fileid) from dbo.sysfiles where name like ''%log%''
   8:     DBCC Shrinkfile (@logfile_id, truncateonly)
   9:         end'
  10:  
  11: exec sp_msforeachdb @ssql

Kommentarer